Difference between revisions of "Developer:Davaar:PlaylistService"

From LinnDocs
Jump to: navigation, search
(SeekIndex)
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Architectural Overview =
+
See http://wiki.openhome.org/wiki/Av:Developer:PlaylistService
 
 
The Playlist service provides the means for controlling a Playlist source. If a device's [[Developer:Davaar:ProductService|Product service]] reports a source of type 'Playlist', then that device is guaranteed to bear the Playlist service.
 
 
 
The Playlist service provides access to a list of tracks, which can be played starting at any point. Unless repeat mode has been engaged, the playlist will play to the end. Shuffle mode causes playback to skip randomly through the playlist. It is possible for Shuffle and Repeat modes to be engaged simultaneously.
 
 
 
Using the Playlist service you can read, insert, and delete entries in the playlist. Each entry in the playlist is given unique id.  This unique id is completely unrelated to the play order of the playlist.
 
 
 
To insert, provide the id you wish to insert 'after' and the associated uri and metadata. The track is inserted into the correct position and the id of the new track is returned.  To insert in the first position in the playlist, insert after the special id of 0.
 
 
 
There are two read actions. One to read a single entry and the other to read a list of entries.
 
 
 
In the first, the uri and metadata of the requested id are returned. This operation can fail if the requested id does not exist in the playlist.
 
 
 
In the second, ReadList, a list of space separated decimal id's is provided and information concerning each of these tracks is returned in xml. ReadList does not fail. Requests for ids that are not in the playlist are silently ignored.
 
 
 
There are two variants of delete allowing the deletion of a single track or the deletion of the entire playlist. The former requires the id of the entry to delete. The latter takes no parameters. Both variants always succeed.
 
 
 
== IdArray ==
 
 
 
The Playlist service has a state variable called IdArray. This IdArray is a [http://en.wikipedia.org/wiki/Base64 base64] encoded array of 32 bit, big endian unsigned integers. Each Id represents a track in the playlist. An empty IdArray indicates an empty playlist.
 
 
 
For example the IdArray of:
 
 
 
<pre>0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x14 0x00 0x00 0x00 0x13</pre>
 
 
 
indicates a playlist of 3 tracks with the id's of 2, 20, and 19 in that order.
 
 
 
Control point authors are interested in both:
 
 
 
* the order of tracks in the playlist, and
 
* the metadata of those tracks
 
 
 
Whether you acquire the IdArray via [[Developer:Davaar:PlaylistService#Events|events]] or [[Developer:Davaar:PlaylistService#Polling|polling]], you immediately know the order of the ids in the playlist.  What you don't necessarily know is the metadata for those ids. 
 
 
 
As the metadata for a large playlist can easily be several megabytes of xml, blindly fetching all the metadata every time the playlist changes is inefficient and will give a poor user experience.  In order to quickly display playlist updates and ensure interoperability with other control points on the network, it is strongly recommended that you maintain the following two data structures:
 
 
 
* A copy of the latest IdArray
 
* A cache mapping id's to their associated metadata.
 
 
 
With this decoupled approach, you only need to fetch the metadata for the ids added to the playlist.  Changes to the order of ids in the playlist require no action.
 
 
 
As a further enhancement, when an insert completes successfully, you know both the metadata (as you supplied it), and the new id (returned by the DS on completion of the insert action).  This information can be directly inserted into the cache, saving subsequent unnecessary retrieval.
 
 
 
== Events ==
 
 
 
A short while (approx 300ms) after any change to the playlist, the DS will event all subscribers the current IdArray. The eventing of this state variable is moderated to prevent excessive updates.
 
 
 
== Polling ==
 
 
 
For control points that can't subscribe to events, two additional actions are provided. The first, IdArray, reads the id array directly. This action also returns an IdArrayToken, which should be saved and periodically passed to a second action, IdArrayChanged, which reports whether or not your copy of the IdArray is out of date. If it is, calling IdArray again will ensure you have an up to date version.
 
 
 
= Actions =
 
 
 
== IdArray ==
 
Report the current id array.
 
 
 
The IdArray is an ordered array of ids that represent each track in the playlist.
 
 
 
This action also reports a Token, which can be used to quickly detect if the id array has changed since it was last read (see IdArrayChanged).
 
 
 
== IdArrayChanged ==
 
Check to see if the id array has changed since gathering the specified Token.
 
This Token must have been previously collected from the IdArray action.
 
 
 
This mechanism is provided specifically for clients unable to partake in UPnP eventing.
 
 
 
== TracksMax ==
 
Report the maximum number of tracks in the id array. This remains constant while a particular Openhome device remains registerted on the network, but may vary between different models of Openhome device from different manufacturers.
 
 
 
==Id==
 
Report the Id of the current track. If the reported id is zero, the playlist is empty.
 
 
 
==ProtocolInfo==
 
Report the Playlist source protocol info.
 
 
 
==Read==
 
Given a track Id, report its associated Uri and Metadata.
 
 
 
==ReadList==
 
Given a space separated list of track Id's, report their associated Uri and Metadata in the following xml form:
 
 
 
<code>
 
 
 
  <TrackList>
 
    <Entry>
 
      <Id></Id>
 
      <Uri></Uri>
 
      <Metadata></Metadata>
 
    </Entry>
 
  </TrackList>
 
 
 
</code>
 
 
 
== TransportState ==
 
 
 
Report the current transport state, which can be: 'Playing', 'Paused', 'Stopped', or 'Buffering'.
 
 
 
== Play ==
 
Begin playback from the current position.
 
 
 
== Pause ==
 
Pause the current track. This will be converted to Stop if the track cannot be paused e.g. internet radio.
 
 
 
== Stop ==
 
Stop playback and move the current position to the start of the current track.
 
 
 
== Next ==
 
Move the current position to the start of the next track in the playlist.
 
 
 
== Previous ==
 
Move the current position to the start of the next track in the playlist.
 
 
 
== SeekId ==
 
Move the current position to the start of the track represented by the given Id.
 
 
 
== SeekIndex ==
 
Move the current position to the start of the track with the given Index into the playlist.
 
 
 
This action should only be used by primitive control points that do not have a rich way of representing the playlist to the user.
 
 
 
== SeekSecondAbsolute ==
 
Seek to an absolute second within the current track. This is only available if the current track has a finite length.
 
 
 
== SeekSecondRelative ==
 
Seek to a relative second within the current track.  This is only available if the current track has a finite length.
 
 
 
== Repeat ==
 
Report the state of repeat mode.
 
 
 
== SetRepeat ==
 
Set the state of repeat mode.
 
 
 
== Shuffle ==
 
Report the state of shuffle mode.
 
 
 
== SetShuffle ==
 
Set the state of shuffle mode.
 
 
 
== DeleteId ==
 
Delete from the playlist the track with the speciofied Id.
 
 
 
== DeleteAll ==
 
Clear the playlist.
 
 
 
= Technical Details =
 
<code>
 
    Domain  : av.openhome.org
 
    Name    : Playlist
 
    Version : 1
 
</code>
 
[http://oss.linn.co.uk/trac/browser/Main/LibUpnpCil/Services/Openhome/Playlist1.xml Playlist Service Description (XML)]
 
 
 
= Migration Guide From Cara =
 
 
 
The domain for the Playlist service has changed to av.openhome.org
 
 
 
The Playlist service aggregates functionality from both the Cara Playlist and Ds services.
 
 
 
== Actions ==
 
 
 
=== TracksMax ===
 
This action has changed its name from IdsMax. The arguments have changed their names as follows:
 
 
 
* aIdsMax -> Value
 
 
 
=== IdArray ===
 
The arguments have changed their names as follows:
 
 
 
* aIdArrayToken -> Token
 
* aIdArray -> Array
 
 
 
=== IdArrayChanged ===
 
The arguments have changed their names as follows:
 
 
 
* aIdArrayToken -> Token
 
* aIdArrayChanged -> Value
 
 
 
=== Id ===
 
The arguments have changed their names as follows:
 
 
 
* aId -> Value
 
 
 
=== ProtocolInfo ===
 
The arguments have changed their names as follows:
 
 
 
* aInfo -> Value
 
 
 
=== Read ===
 
The arguments have changed their names as follows:
 
 
 
* aId -> Id
 
* aMetadata -> Metadata
 
 
 
=== ReadList ===
 
The arguments have changed their names as follows:
 
 
 
* aIdList -> IdList
 
* aMetadataList -> TrackList
 
 
 
The IdList passed in has changed from comma-separated to space-separated.
 
 
 
The xml returned has changed to be of the following form:
 
 
 
<code>
 
 
 
  <TrackList>
 
    <Entry>
 
      <Id></Id>
 
      <Metadata></Metadata>
 
    </Entry>
 
  </TrackList>
 
 
 
</code>
 
 
 
=== DeleteId ===
 
The name of the action has changed from Delete.
 
 
 
The arguments have changed their names as follows:
 
 
 
* aId -> Value
 
 
 
=== DeleteAll ===
 
No change
 
 
 
=== Insert ===
 
The arguments have changed their names as follows:
 
 
 
* aAfterId -> AfterId
 
* aUri -> Uri
 
* aMetadata -> Metadata
 
* aNewId -> NewId
 
 
 
=== TransportState ===
 
The arguments have changed their names as follows:
 
 
 
* aState -> Value
 
 
 
=== Play ===
 
No change
 
 
 
=== Pause ===
 
No change
 
 
 
=== Stop ===
 
No change
 
 
 
=== SeekSecondsAbsolute ===
 
The arguments have changed their names as follows:
 
 
 
* aSecond -> Value
 
 
 
=== SeekSecondsRelative ===
 
The arguments have changed their names as follows:
 
 
 
* aSecond -> Value
 
 
 
=== SeekId ===
 
The name of the action has changed from SeekTrackId.
 
 
 
The arguments have changed their names as follows:
 
 
 
* aTrackId -> Value
 
 
 
=== SeekIndex ===
 
The name of the action has changed from SeekTrackAbsolute.
 
 
 
The arguments have changed their names as follows:
 
 
 
* aTrack -> Value
 
 
 
=== Next ===
 
Replaces some of the functionality of SeekTrackRelative.
 
 
 
=== Previous ===
 
Replaces some of the functionality of SeekTrackRelative.
 

Latest revision as of 08:40, 21 November 2018