Play audio or video

Playing audio or video in mm-renderer requires that you configure a context, attach outputs and an input, and then issue playback commands. These actions are all done using function calls to the Multimedia Renderer Client API.

To play audio or video in mm-renderer:
  1. Connect to mm-renderer using the mmr_connect() function.
  2. Create a context and set the appropriate context parameters. Use the mmr_context_create() and mmr_context_parameters() functions.
  3. Attach an output and set its output parameters. Use the mmr_output_attach() and mmr_output_parameters() functions. You can attach multiple outputs.
  4. Attach the input and set the input parameters. Use the mmr_input_attach() and mmr_input_parameters() functions.
  5. Start playback for the context by calling the mmr_play() function.

Play states

The possible play states of the context are:

No input is attached.
Input is attached but isn't playing.
Input is attached and is playing.

There is no paused play state. A play speed of 0 represents paused playback.

Play speed

In mm-renderer, the play speed is represented by an integer. Normal speed is represented by a value of 1000 and 0 means paused. Trick play refers to playing media at other speeds such as negative (reverse), slower than normal, or faster than normal. The context's input media dictates whether trick play is supported.

Use the mmr_speed_set() function to change the current play speed. You can change the speed when the state is stopped; mm-renderer saves the setting and applies it when playback restarts.

Seeking to positions

Use the mmr_seek() function to seek for a known position in a single track or a track in a playlist.

When the current context input is a track, you must specify the track position in milliseconds (for example "2500").

When the context input is a playlist, the position must be a string in the format "99:9999" (for example "2:1200") where the first number is the track position in the current playlist and the second number is the number of milliseconds from the beginning of the specified track.


A metadata event occurs when mm-renderer publishes metadata. One such example is when a radio station publishes metadata about a song that's playing and updates the metadata whenever a new song starts.

You can retrieve mm-renderer events by calling the mmr_event_get() function.

When the type of the returned mmr_event_t is MMR_EVENT_METADATA, then a metadata event has occurred and the published metadata can be found in the data dictionary of the mmr_event_t structure.

When you're playing a playlist, it's important to distinguish input metadata from track metadata, similar to distinguishing input parameters from track parameters. A track index of 0 in the mmr_event_t structure indicates that the metadata describes the playlist. A nonzero track index indicates that the metadata describes a track.

Track metadata is published as soon as it's known, which can be long before the track is played. There are typically two events that occur for a track that includes metadata. The first event occurs when the track enters the playlist window and the metadata consists of the track's URL. The second event occurs when mm-renderer opens the file and examines its content, and the event structure is filled with more detailed information. When the track leaves the playlist window, an event occurs where the event structure contains that track's index, but has a null pointer for the metadata dictionary.

A static file usually doesn't generate more than two metadata events. Currently, dynamic metadata with changing titles are generated only for radio-style streams.

You can use the strm_dict_find_*() functions from the Dictionary Object Library to search the data dictionary for the following metadata:

  • Track name (md_title_name)
  • Artist name (md_title_artist)
  • Album name (md_title_album)
  • Genre (md_title_genre)
  • Text comment (md_title_comment)
  • Track length (md_title_duration)
  • Track number (md_title_track)
  • Disc number (md_title_disc)
  • Number of samples for each time unit (md_title_samplerate)
  • Track bit rate (md_title_bitrate)
  • Whether the track is DRM-protected (md_title_protected)
  • Whether the track supports seeking (md_title_seekable)
  • Whether the track can be paused (md_title_pausable)
  • Track media type (md_title_mediatype)
  • Video width, in physical units (md_video_width)
  • Video height, in physical units (md_video_height)
  • Track art (md_title_art)
  • Video width, in pixels (md_video_pixel_width)
  • Video height, in pixels(md_video_pixel_height)
  • Compilation title (md_title_compilation)
  • Album artist name (md_title_albumartist)
  • Composer name (md_title_composer)
  • Track year (md_title_year)

The data dictionary may also contain the following metadata for tracks or images at a specific index (%u):

Index metadata Parsed metadata
md_audio_track%u sample_rate, bitrate, fourcc, lang
md_video_track%u frame_rate, bitrate, width, height, pixel_width, pixel_height, fourcc, lang
md_subpicture_track%u width, height, pixel_width, pixel_height, fourcc, lang
md_title_image%u width, height, mime, type, url, file

You can call the mmr_metadata_split() function to parse the track and image data. The following code sample shows you how to parse the metadata for the audio track whose track index is 12. The code sample shows a call that searches the dictionary that md points to for an entry whose name is "md_audio_track12". Indexed metadata items range from 0 to N-1 with no gaps in the numbering. Any parsed properties are returned in a dictionary that you can search using the strm_dict_find_*() functions.

mmr_metadata_split(md, "audio", 12);

Switching tracks

In API level 10.3.1 or later, mm-renderer allows switching audio tracks in supported file formats and publishes track-specific metadata for audio, video, and subpicture tracks.

You can use the audio_index parameter to specify which audio track to play and the subpicture_index parameter to control which subtitle to display.

Metadata for each track is encoded in a single attribute in the dictionary object that is received in a metadata event. Call the mmr_metadata_split() function to search this dictionary for the attributes describing the requested track. The function returns the track metadata as a new dictionary object.

This code sample shows you how to use a loop to search a dictionary for available audio tracks:

Not applicable

Not applicable

for ( int ndx = 0; 
      (trackinfo = mmr_metadata_split(metadata, "audio", ndx)) != NULL;
    //  Now you can search the trackinfo dictionary for useful stuff, 
    //  details, or maybe display things in a list and let the
    //  user pick a track

To use the audio track from position ndx, convert ndx to a decimal string and add the string as the audio_index parameter to your track parameter dictionary. Switch to that audio track by calling the mmr_track_parameters() or mmr_input_parameters() function when "track" is your input type.

Last modified: 2015-07-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus