Playback examples

The following mmrplay commands demonstrate common use cases of playing or recording media files. The media files accessed here are encoded in popular formats such as MP3, M4A, and WMA, but all mmrplay commands have the same syntax and support the same options, regardless of the file format.

In these examples, the input URLs are pathnames in the local filesystem. These can be the paths of uploaded files or files stored on connected devices. When you attach a mediastore to your system, the device publisher that monitors devices of the relevant type will publish its mountpoint to a PPS object in /pps/qnx/mount/. For instance, when you plug in a USB stick, the usblauncher service assigns it a mountpoint of /fs/usb0 (or something similar). For information on how the publishers assign mountpoints and publish device information, see the Device Publishers Developer's Guide.

The mmrplay commands automate the tasks of attaching outputs and inputs and configuring their parameters, which must be done in separate mm-renderer API calls before you can play media files. For examples of all mm-renderer actions needed to configure and control media file playback, see "Using mmcli to play media files".

Playing an audio file

To play an MP3 audio file located on an attached USB stick over the default audio device, enter a command like this:
# mmrplay /fs/usb0/stillness_in_time.mp3

This command doesn't name an audio output URL using -a, so mmrplay will output the media file to the default audio device. In this case, an output URL of audio:default is sent to mm-renderer, which makes it use automated audio routing with the Audio Manager service. If mm-renderer doesn't accept this URL, mmrplay then sends it the device pathname of the preferred audio device (e.g., /dev/snd/pcmPreferredp). If mm-renderer can't use this device either, the command fails.

You can set the volume by defining it as an audio output parameter with the -A option. You can also explicitly state that the input type is a track by using -t:
# mmrplay -A volume=30 -t track /fs/usb0/stillness_in_time.mp3 

The output device is independent of the input format, so you would use the same command syntax to play other audio file types (e.g., WMA, WAV), except that your input URL would contain a different file extension.

Playing a playlist

The command syntax for playing the tracks in a playlist is similar to that for playing an individual track, except that you must state the playlist input type (using -t) and you can also set the repeat input parameter (using -I):
# mmrplay -t playlist -I repeat=none /fs/usb0/u2_best_of_80s.m3u 

This command sets the repeat mode to none to prevent mm-renderer from continuously playing either a single track or the entire set of tracks in the playlist. If you set a different repeat mode (e.g., all), mmrplay would initiate playback in mm-renderer but then wait indefinitely for the playback to stop (because it would never receive an event indicating that playback has stopped).

In this case, you would have to use the mm-renderer API or mmcli to explicitly stop playback in the context created by mmrplay. Stopping playback in a context requires knowing its name, which can be set with -c:
# mmrplay -c test_playlist_looping -t playlist -I repeat=all \

Here, mmrplay creates a context called test_playlist_looping and starts continuous playback of the entire track set in the u2_best_of_80s.m3u playlist. To stop playback in an application or mmcli, you must connect to mm-renderer (using mmr_connect()), open the test_playlist_looping context (using mmr_context_open()), and then stop playback (using mmr_stop()). For details on working with mm-renderer, see the Multimedia Renderer Developer's Guide.

Playing a video file

To play an MP4 video file, enter a command like this:
# mmrplay -v screen: /fs/usb0/seven_days_live.mp4 

Here, the video output URL has a prefix of screen: to tell mm-renderer to output the video stream to the Screen Graphics Subsystem, which renders it to the display. You can set some properties of the output window in this type of URL, as explained in the mmr_output_attach() function reference.

If you want to play video without any audio, you can add the -a option and specify an empty URL:
# mmrplay -a "" -v screen: /fs/usb0/seven_days_live.mp4 

Recording audio content

To record audio content to a file, enter a command like this:

# mmrplay -c test_audio_recording -f /tmp/my_karaoke.wav \

This command directs the audio output to a WAV file specified by -f. Here, the input URL names the preferred audio capture device and sets parameters for the sampling rate (frate) and the number of channels (nchan). You can find a list of all supported parameters for this URL type in the mmr_input_attach() reference.

Note: The snd: input URL type works only with file output, so you must provide a file output URL when using this input URL type.

Similar to playing a playlist with the repeat mode enabled, recording audio content causes mmrplay to initiate playback with mm-renderer but to never process an event indicating playback has stopped. If you start recording audio with mmrplay, you must then explicitly stop the recording by stopping playback in the relevant context, by either directly calling the mm-renderer API or using mmcli.