Media Playback

The Media Player and other HMI apps can play media files through mm-player. The mm-player plugins manage their own tracksessions (track sequences) and support playback by using mm-renderer and device-specific components to control media streams.

The interaction between these components proceeds like this:

Architectural diagram with media playback components highlighted and their order of interaction enumerated
Figure 1. Media playback
  1. Sending tracksession and playback requests

    To send tracksession and playback requests to mm-player, HMI apps call functions in either the car.mediaplayer WebWorks extension (for the HTML5 HMI) or the QtQnxCar2 library (for the Qt5 HMI), which then forwards the requests to the C API of mm-player.

    The tracksession operations exposed by each of these components include but are not limited to:
    • createTrackSession
    • destroyTrackSession
    • getCurrentTrack
    • getTrackSessionItems
    The playback operations exposed include but are not limited to:
    • play
    • stop
    • setPlaybackRate
    • seek
    • next
    • previous
    • shuffle
  2. Managing tracksessions and playing media

    The mm-player service uses tracksessions to store playback sequences of tracks. For commands related solely to tracksession management (e.g., createTrackSession, deleteTrackSession), mm-player creates, deletes, or updates its internal data structures that store tracksession information, but then skips the rest of this step.

    For commands affecting playback activity (e.g., play, setPlaybackRate), mm-player reads its tracksession data structures to determine which track to play next based on the requested operation. For instance, when processing the next command, mm-player:

    1. Retrieves the index of the next track

      Each tracksession stores a sequential track list, which lists tracks in their relative order defined at the media source, and a randomized track list, which lists track in a random order generated when an app issues the shuffle command. The list that mm-player reads the index of the next track from depends on the shuffle setting.

    2. Retrieves the metadata and the URL of the next track

      Using the index of the next track, mm-player looks up the track's URL and metadata, which are also stored in the tracksession. The URL indicates the location of the media file that will become the new input to mm-renderer. The metadata contains track creation and runtime information that mm-player can deliver to HMI apps so that they can refresh their display to show the newly selected track.

    To manage playback, mm-player uses device-specific components to start and stop media streams from devices and uses mm-renderer to direct the media content to the designated output.

    Each plugin interacts with different libraries and drivers to direct playback commands to the devices that it supports. For example, the iPod plugin sends commands to the ipodlib library, which communicates with the driver that manages the audio device that the iPod is connected to. The plugin also provides mm-renderer with the URL of the device path (i.e., /dev entry) for this same device, to attach it as the input. When the library instructs the device driver to set its media sampling rate above 0, the media content starts flowing from the iPod, through the audio device, to mm-renderer. As it does with all plugins, the mm-renderer service then directs the media flow to the io-audio utility, which outputs it over the designated hardware (e.g., speakers).

    For a more detailed explanation of playback, see the "Media playback" section in the Multimedia Architecture Guide for the QNX SDK for Apps and Media.

    Note: In this release, mm-player doesn't support video playback (only audio). To play videos, your apps must use the HTML5 video features.
  3. Reporting tracksession and playback state

    After the necessary tracksession and playback actions are carried out by a plugin, the mm-player service delivers any results data to the HMI through either the car.mediaplayer extension or the QtQnxCar2 library, depending on which HMI version is in use. For examples of retrieving results data after issuing function calls or REST requests to the first of these mechanisms, see the "car.mediaplayer.Mediaplayer" section.

    The getTrackSessionItems and getCurrentTrack operations return information for tracksession items that includes but is not limited to:
    • filepath
    • media item type (e.g., audio, video, folder)
    The getCurrentTrack operation also returns metadata, which includes but is not limited to:
    • artist name
    • album name
    • track title
    • duration (runtime)

    The playback operations listed in Step 1 don't produce any new playback data. For these operations, no new information needs to be communicated to the HMI, so the WebWorks extension or the Qt library returns only a Boolean field indicating if the operation succeeded or failed.

    The plugins also notify mm-player when any serious playback error occurs, so that the service can inform HMI apps when a playback operation fails.