It seems like the browser you are using has JavaScript disabled. As a result, the site will not function properly. We really want you to enable it so you may experience our site as we intended it. If you have no idea what we are talking about or if you need help, visit http://www.enable-javascript.com×
This website uses cookies. By continuing to browse this site you are agreeing to our use of cookies. Find out more on our cookie page.×

Oops, it seems like you're using an old browser that we do not fully support. If you're able to, please upgrade your browser here.×
This website uses cookies. By continuing to browse this site you are agreeing to our use of cookies. Find out more on our cookie page.×

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.

Play states

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.

Metadata

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):

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.

Switching 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:

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.

1. Download the tools

Before you start developing, you'll need to visit the Downloads tab. Here you'll find downloads for the BlackBerry 10 Native SDK, BlackBerry 10 Device Simulator, and some other useful tools.

2. Try the sample apps

Now featuring a filter control, the Sample apps tab allows you to search for samples by name or by feature.

Select either the Core or Cascades radio buttons to display the samples relevant to you.

3. Educate yourself

The Documentation tab contains tons of examples, tutorials, and best practices to guide you along the path towards building an awesome app.

You can access all the documentation that you need in the left-hand navigation.

4. Start developing

The Reference tab is where you'll find essential details about how to use our APIs.

You can use the left-hand navigation to choose how you would like to browse the reference: by module, by topic, or alphabetically. If you have an idea of what you are looking for, start typing it in the Filter box.