Managing Playback

Playback on media devices may be initiated or changed by:

This chapter presents the control message sequences and the settings that a device controller may need to support to monitor and manage media playback through devctl() calls to MediaFS entities. It contains the following sections:

For a list of MediaFS control messages, see the chapters Playback Messages and Metadata Messages.

Requested playback control sequences

A media device controller using MediaFS should support client applications issuing commands to MediaFS entities to start playback of:

This section presents the control message sequences and settings required to effect a playback state change through a devctl() call to a MediaFS entity. It contains:

Start playback — file or directory

To start playback for a specific file or directory, the client application should issue, as required, either the DCMD_MEDIA_PLAY or the DCMD_MEDIA_PLAY_AT device control message to the MediaFS file or directory to play.

If the file or directory is valid for the media device, the device controller must perform the following operations, in sequence:

  1. Receive the device control message, and validate playback.
  2. Start playback of the requested track on the media device.
  3. Update the following _media_playback structure members:
  4. Update the MediaFS current symbolic link (if it is present) to point to the requested media file.
  5. Send an out-of-band notification on the control file.
  6. If all operations are successful, reply to the device control message with EOK.

Start playback — media device

Some media devices support playback of the entire device, starting with the first track in the device, a random track, or at the point where playback was previously stopped. To start or resume playback of a device, a client application should issue the DCMD_MEDIA_PLAY device control message to the MediaFS control file.

If this action is valid for the current media device, the device controller must perform the following operations, in sequence:

  1. Receive the device control message, and validate playback.
  2. Start playback of the media device.
  3. Update the following _media_playback structure members:
  4. Update the current symbolic link to point to the requested media file. If the currently playing file is not known at this time, clear the symbolic link.
  5. Send an out-of-band notification on the control file.
  6. If all operations are successful, reply to the device control message with EOK.

Track information updates

If a device autonomously indicates the playing track after MediaFS has replied to the DCMD_MEDIA_PLAY device control message that started playback, the device controller must perform the following operations, in sequence:

  1. Update the following _media_playback structure members:
  2. Send an out-of-band notification on the control file.

Fast forward and reverse

The playback speed or direction of a media device represented through MediaFS can be changed only while the device is in the playing state. To change the playback speed or direction, or both, the client application should issue the appropriate messages to the the MediaFS control file.

If the action is valid for the current media device, the device controller must perform the following operations, in sequence:

  1. Receive the device control message, and validate playback.
  2. Change the playback speed on the media device, as requested.
  3. Update the following _media_playback structure members:
  4. Send an out-of-band notification on the control file.
  5. If all operations are successful, reply to the device control message with EOK.

For more information about fast forward and reverse control messages, see the chapter Playback and Status Messages.

Pause and resume playback

The client application should pause and resume playback on MediaFS devices by issuing messages to the MediaFS control file. If these actions are valid for the current media device, the device control should apply them to the device.

Pause playback

Playback can only be paused while a device is in the playing state. To pause playback, a client application should issue the DCMD_MEDIA_PAUSE message to the MediaFS control file. If this action is valid for the current media device, the device controller must perform the following operations, in sequence:

  1. Receive the device control message, and validate playback.
  2. Pause playback on the media device.
  3. Update the following _media_playback structure members:
  4. Send an out-of-band notification on the control file.
  5. If all operations are successful, reply to the device control message with EOK.

Resume playback

Playback can only be resumed while the device is in the paused state. To resume playback, the client application should issue the DCMD_MEDIA_RESUME message to the MediaFS control file. If this action is valid for the current media device, the device controller must perform the following operations, in sequence:

  1. Receive the device control message, and validate playback.
  2. Resume playback paused on the media device.
  3. Update the following _media_playback structure members:
  4. Send an out-of-band notification on the control file.
  5. If all operations are successful, reply to the device control message with EOK.

Managing autonomous playback state changes

During playback, a media device may change playback or metadata states autonomously, independently of any user request. This section describes the actions that a device controller must perform when it encounters a device-initiated state change:

Track change

If a media device autonomously changes tracks, the device controller must perform the following operations, in sequence:

  1. Update the following _media_playback structure members:
  2. Update the current symbolic link to point to the new currently playing MediaFS file.
  3. Send an out-of-band notification on the control file.

Playback state change

Some media devices may autonomously pause, stop, or resume playback. If these state changes occur on a media device, the device controller must perform the following operations, in sequence:

  1. Update the following _media_playback structure members:
  2. Send an out-of-band notification on the control file.

Metadata update

If a media device supports asynchronous metadata updates, it may update the metadata for the current playing track. If an update of this type occurs, the device controller must perform the following operations, in sequence:

  1. Update the following _media_playback structure member:
  2. Send an out-of-band notification on the control file.

Subsequent client application requests for metadata (made through a device control message to a MediaFS entity) will retrieve the new metadata that was received from the media device.