Using the now playing service

To use the now playing service, applications should register with the service, and publish and subscribe to the relevant PPS objects.

Managing audio

The audio manager looks after audio routing to output devices (and from input devices), and attenuating or muting output according to configured audio type priorities. When your application opens a PCM stream, it should also get an audio manager handle so that the audio manager will know about the stream. You should specify the same audio stream type for the audio manager handle as for the PCM stream handle to ensure that audio manager routes, and attenuates or mutes the audio stream as specificied by your system's configuration.

To get a PCM stream handle and an audio manager handle, call audio_manager_snd_pcm_open(), then audio_manager_get_handle(); or audio_manager_snd_pcm_open_name().

Managing playback

The audio manager doesn't look after your application's media playback, however. If you open a PCM stream and get an audio manager handle for that stream but do not use the now playing service, when your application's audio is muted or attenuated (ducked), playback will continue. To ensure that the preferred behavior can be implemented, your application should:

  1. Register with the now playing service, and publish its activities to the appropriate PPS objects:
  2. Subscribe to /pps/services/multimedia/mediaplayer/status to receive the status updates that the now playing service publishes to this object.
  3. When it learns that the status of its audio stream has changed, stop, pause, resume, or allow playback to continue, as required.
Note: The now playing service does not control audio output or playback. It informs applications that have registered with the PPS objects it uses of changes in the status of audio streams. The decision of what to do when the status of an audio stream changes is the responsibility of your application.

For more information about PPS, see the QNX Persistent Publish/Subscribe Developer's Guide