Playback examples

Updated: April 19, 2023

In this section, we provide mmrplay commands that demonstrate how to play or record 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, for any 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 attached mediastores. When you attach a mediastore to your system, the appropriate device publisher assigns it a mountpoint. For instance, when you plug in a USB stick, the usblauncher service assigns it a mountpoint of /fs/usb0 (or something similar). You can then look for media files under this mountpoint. For information on how the publishers assign and publish mountpoints, see the Device Publishers Developer's Guide.

The mmrplay utility automates specifying outputs and inputs and configuring their parameters, which in mm-renderer must be done with multiple API calls before you can play media files. For examples of all mm-renderer actions needed to play content, 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 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 send a URL of snd: to mm-renderer to open the preferred device, which is explained in the Audio Developer's Guide.

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.

You can also specify the minimum and maximum latency (in milliseconds) on the target system, as in this example that names a PCM audio output device and an HTTP-accessible audio file as input:
# mmrplay -C minlatency=120 -C maxlatency=500 \
          -a snd:/dev/snd/pcmC0D0p https://path-to-internet-audio-file

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 that the input type is a playlist (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 \
          /fs/usb0/u2_best_of_80s.m3u 

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, open the test_playlist_looping context, and stop playback. For information about doing these steps, see the Multimedia Renderer Developer's Guide.

Playing a video file

To play a 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 on the display. You can set some properties of the output window in this type of URL, as explained in the Managing video windows section of the Multimedia Renderer Developer's Guide.

Because no -a option is given in the above command line, in this case, mm-renderer uses the preferred audio device to output the audio content (if any). If you want to explicitly disable audio output while playing video, 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 \
          snd:/dev/snd/pcmPreferredc?frate=44100&nchan=2 

This command directs the audio output to a WAV file specified by -f. Here, the input URL names the preferred audio capture device (microphone) 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 Recording audio data section of the Multimedia Renderer Developer's Guide.

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.