Updated: October 28, 2024 |
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.
# 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.
# 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.
# mmrplay -C minlatency=120 -C maxlatency=500 \ -a snd:/dev/snd/pcmC0D0p https://path-to-internet-audio-file
# 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).
# 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.
# 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.
# mmrplay -a "" -v screen: /fs/usb0/seven_days_live.mp4
# 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.
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.