Skip to main content
Version: 20 Mar 2024

MLMediaFormat

NameSpace: MagicLeap

APIs for creating and retrieving media format information.

Public Fields

Handle

Handle for the underlying unmanaged object.


public ulong Handle { get; set; }


Public Methods

MLMediaFormat CreateAudio

Create a audio format object.

public static MLMediaFormat CreateAudio(
string mimeType,
int sampleRate,
int channelCount
)

Parameters

TypeNameDescription
stringmimeTypeMime type of the content
intsampleRateSample rate of the content
intchannelCountNumber of audio channels

Returns: An MLMediaFormat object if successful, null otherwise


MLMediaFormat CreateCopy

Create a copy of the format handle provided.

public static MLMediaFormat CreateCopy(
MLMediaFormat format
)

Parameters

TypeNameDescription
MLMediaFormatformatMLMediaFormat object to copy

Details*

This can be particularly useful to persist the media format handle/object that was received through the callbacks(as life cycle of those media format objects are with in the callback context only). The API call to make a copy ensures that the copied object exists until released by the app.

Returns: An MLMediaFormat object if successful, null otherwise


MLMediaFormat CreateEmpty

Create an empty format object.

public static MLMediaFormat CreateEmpty()

Returns: An MLMediaFormat object if successful, null otherwise


MLMediaFormat CreateSubtitle

Create a subtitle format object.

public static MLMediaFormat CreateSubtitle(
string mimeType,
string language
)

Parameters

TypeNameDescription
stringmimeTypeMime type of the content
stringlanguageLanguage of the content, using either ISO 639-1 or 639-2/T codes. Specify null or "und" if language information is only included in the content.

Returns: An MLMediaFormat object if successful, null otherwise


MLMediaFormat CreateVideo

Create a video format object.

public static MLMediaFormat CreateVideo(
string mimeType,
int width,
int height
)

Parameters

TypeNameDescription
stringmimeTypeMime type of the content
intwidthWidth of the content in pixels
intheightHeight of the content in pixels

Returns: An MLMediaFormat object if successful, null otherwise


MLResult GetValue

Obtain the value of an integer key.

public MLResult GetValue(
string keyName,
out int value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to get the value for
out intvalueOut param to get the value in

Returns: MLResult.Result.Ok if value was obtained successfully


MLResult GetValue

Obtain the value of a long key.

public MLResult GetValue(
string keyName,
out long value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to get the value for
out longvalueOut param to get the value in

Returns: MLResult.Result.Ok if value was obtained successfully


MLResult GetValue

Obtain the value of a float key.

public MLResult GetValue(
string keyName,
out float value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to get the value for
out floatvalueOut param to get the value in

Returns: MLResult.Result.Ok if value was obtained successfully


MLResult GetValue

Obtain the value of a string key.

public MLResult GetValue(
string keyName,
out string value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to get the value for
out stringvalueOut param to get the value in

Returns: MLResult.Result.Ok if value was obtained successfully


MLResult GetValue

Obtain the value of a byte buffer key.

public MLResult GetValue(
string keyName,
out byte [] value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to get the value for
out byte []valueOut param to get the value in

Returns: MLResult.Result.Ok if value was obtained successfully


MLResult GetValue

Obtain the value of an unsigned long key.

public MLResult GetValue(
string keyName,
out ulong size
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to get the value for
out ulongvalueOut param to get the value in

Returns: MLResult.Result.Ok if value was obtained successfully


MLResult SetValue

Set the value of an integer key.

public MLResult SetValue(
string keyName,
int value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to set the value for
intvalueValue to set

Returns: MLResult.Result.Ok if value was set successfully


MLResult SetValue

Set the value of a long key.

public MLResult SetValue(
string keyName,
long value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to set the value for
longvalueValue to set

Returns: MLResult.Result.Ok if value was set successfully


MLResult SetValue

Set the value of a float key.

public MLResult SetValue(
string keyName,
float value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to set the value for
floatvalueValue to set

Returns: MLResult.Result.Ok if value was set successfully


MLResult SetValue

Set the value of a string key.

public MLResult SetValue(
string keyName,
string value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to set the value for
stringvalueValue to set

Returns: MLResult.Result.Ok if value was set successfully


MLResult SetValue

Set the value of a byte buffer key.

public MLResult SetValue(
string keyName,
byte [] value
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to set the value for
byte []valueValue to set

Returns: MLResult.Result.Ok if value was set successfully


MLResult SetValue

Set the value of an unsigned long key.

public MLResult SetValue(
string keyName,
ulong size
)

Parameters

TypeNameDescription
stringkeyNameMLMediaFormatKey name to set the value for
ulongvalueValue to set

Returns: MLResult.Result.Ok if value was set successfully


override string ToString

Human readable representation of the format.

public override string ToString()

Returns: Human readable representation of the format.


Public Enums

AudioEncoding

Audio data format for track type.

EnumeratorValueDescription
None0
PCM16Bits2Audio data format: PCM 16 bits per sample.
PCM8Bits3Audio data format: PCM 8 bits per sample.
PCMFloat4Audio data format: single-precision floating-point per sample.
PCM32Bits201Audio data format: PCM 32 bits per sample.