Playback on media devices may be initiated or changed by:
- a user; that is, a high-level application, such as the MME
- a media device, such as an iPod
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.
A media device controller using MediaFS should support client applications issuing commands to MediaFS entities to start playback of:
- a media file (track), at the start of the track or at an offset, if the media device supports playback from an offset
- a directory
- a media device, if the media device supports this action
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:
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:
- Receive the device control message, and validate playback.
- Start playback of the requested track on the media device.
- Update the following _media_playback structure members:
- count — set to the number of tracks that will be played
- index — set to the index of the requested track
- state — set to PLAYBACK_STATE_PLAY
- flags — if the media device supports this feature, set to PLAYBACK_FLAG_SPEED_EXACT only; if the device does not support this feature, set to 0 (zero)
- metaseq — set to 0 (zero)
- length — set to the length of the track, or to 0 (zero) if the track length is not available
- elapsed — set to 0 (zero) if the DCMD_MEDIA_PLAY message was issued, or to the track start offset, in seconds, if the DCMD_MEDIA_PLAY_AT message was issued and is supported
- speed — if the the flags member is set to PLAYBACK_FLAG_SPEED_EXACT, set to 1 (one) only; no other value is permitted
- Update the MediaFS current symbolic link (if it is present) to point to the requested media file.
- Send an out-of-band notification on the control file.
- If all operations are successful, reply to the device control message with EOK.
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:
- Receive the device control message, and validate playback.
- Start playback of the media device.
- Update the following _media_playback structure members:
- count — set to either 1 (one) if only one track will be played, or to the number of tracks that will be played
- index — set to the currently playing track if the device provides this information immediately, or to 0 (zero) if the information is not provided at this time
- state — set to PLAYBACK_STATE_PLAY
- flags — if the media device supports this feature, set to PLAYBACK_FLAG_SPEED_EXACT only; no other value is permitted
- metaseq — set to 0 (zero)
- length — set to the length of the track, or 0 (zero) if the length is unavailable
- elapsed — set to 0 (zero)
- speed — set to 1 (one), only if the PLAYBACK_FLAG_SPEED_EXACT flag is set; no other value is permitted
- 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.
- Send an out-of-band notification on the control file.
- If all operations are successful, reply to the device control message with EOK.
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:
- Update the following _media_playback structure members:
- count — set to either 1 (one) if only one track will be played, or to the number of tracks that will be played
- index — set to the currently playing track
- metaseq — increment by 1 (one), if metadata is now available
- length — set to the length of the track, or 0 (zero) if the length is unavailable
- elapsed — set to the current track time received from the media device
- Send an out-of-band notification on the control file.
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:
- Receive the device control message, and validate playback.
- Change the playback speed on the media device, as requested.
- Update the following _media_playback structure members:
- state — set to PLAYBACK_STATE_PLAY (1)
- flags — set to PLAYBACK_FLAG_FASTFWD or PLAYBACK_FLAG_FASTRWD, and set to PLAYBACK_FLAG_SPEED_EXACT if the device supports this feature
- speed — set to the playback speed, only if the PLAYBACK_FLAG_SPEED_EXACT flag is set
- Send an out-of-band notification on the control file.
- 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.
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.
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:
- Receive the device control message, and validate playback.
- Pause playback on the media device.
- Update the following _media_playback structure members:
- state — set to PLAYBACK_STATE_PAUSE
- speed — set to 0 (zero), only if the PLAYBACK_FLAG_SPEED_EXACT flag is set
- Send an out-of-band notification on the control file.
- If all operations are successful, reply to the device control message with EOK.
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:
- Receive the device control message, and validate playback.
- Resume playback paused on the media device.
- Update the following _media_playback structure members:
- state — set to PLAYBACK_STATE_PLAY
- speed — set to the device speed, only if the PLAYBACK_FLAG_SPEED_EXACT flag is set
- Send an out-of-band notification on the control file.
- If all operations are successful, reply to the device control message with EOK.
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:
If a media device autonomously changes tracks, the device controller must perform the following operations, in sequence:
- Update the following _media_playback structure members:
- count — set to the number of tracks that will be played
- index — set to the new currently playing track
- metaseq — set to 0
- length — set to the length of the track, or 0 (zero) if the length is unavailable
- elapsed — set to 0 (zero)
- Update the current symbolic link to point to the new currently playing MediaFS file.
- Send an out-of-band notification on the control file.
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:
- Update the following _media_playback structure members:
- state — set to the new playback state
- speed — set to the device speed, only if the PLAYBACK_FLAG_SPEED_EXACT flag is set
- Send an out-of-band notification on the control file.
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:
- Update the following _media_playback structure member:
- metaseq — increment by 1 (one)
- 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.