MediaQueueManager

public class MediaQueueManager extends Object

The class for manipulating the media queue which overrides the default queue translated from MediaSession.

Public Method Summary

int
autoGenerateItemId()
Allocate a new unique item ID.
void
clear()
Clears all overrides in this MediaQueueManager.
Integer
getCurrentItemId()
Returns the current item ID to override in MediaStatus.
MediaQueueData
getMediaQueueData()
Returns the MediaQueueData that is being used to override in MediaStatus.
List<MediaQueueItem>
getQueueItems()
Returns the current list of items that is being used to override in MediaStatus.
Integer
getQueueRepeatMode()
Returns the queue repeat mode to override in MediaStatus.
void
notifyItemsChanged(List<Integer> itemIds)
Notifies that some items in the queue has changed.
void
notifyItemsInserted(List<Integer> itemIds, Integer insertBefore)
Notifies that items has been inserted into the queue.
void
notifyItemsRemoved(List<Integer> itemIds)
Notifies that items has been removed from the queue.
void
notifyQueueFullUpdate()
Notifies that the entire queue has been changed.
MediaQueueManager
setCurrentItemId(Integer currentItemId)
Sets the current item ID to override in MediaStatus.
MediaQueueManager
setMediaQueueData(MediaQueueData queueData)
Sets the MediaQueueData to override in MediaStatus.
MediaQueueManager
setQueueItems(List<MediaQueueItem> queueItems)
Sets the list of items to override the items in MediaStatus.
MediaQueueManager
setQueueRepeatMode(Integer queueRepeatMode)
Sets the queue repeat mode to override in MediaStatus.
void
setQueueStatusLimit(boolean limitQueueItemsInStatus)
Sets whether to limit the number of queue items to be reported in MediaStatus.

Inherited Method Summary

Public Methods

public int autoGenerateItemId ()

Allocate a new unique item ID.

The returned item ID is guaranteed to be unique from previous auto-generated item IDs. This is especially useful when you insert new items to the queue. You should call this method to obtain new item IDs for the new items, and use MediaQueueItemWriter.setItemId(int) or MediaQueueItem.Builder#setItemId(int) to set the ID of the new items. Note that MediaManager.setDataFromLoad(MediaLoadRequestData) also internally use this method to auto-assign item IDs.

You can also opt-out of the item ID auto-assignment and completely manage item IDs on your own, but please do not mix auto-assigned item IDs and your managed item IDs as this can cause conflict.

public void clear ()

Clears all overrides in this MediaQueueManager.

public Integer getCurrentItemId ()

Returns the current item ID to override in MediaStatus.

public MediaQueueData getMediaQueueData ()

Returns the MediaQueueData that is being used to override in MediaStatus.

public List<MediaQueueItem> getQueueItems ()

Returns the current list of items that is being used to override in MediaStatus.

public Integer getQueueRepeatMode ()

Returns the queue repeat mode to override in MediaStatus.

public void notifyItemsChanged (List<Integer> itemIds)

Notifies that some items in the queue has changed.

public void notifyItemsInserted (List<Integer> itemIds, Integer insertBefore)

Notifies that items has been inserted into the queue.

public void notifyItemsRemoved (List<Integer> itemIds)

Notifies that items has been removed from the queue.

public void notifyQueueFullUpdate ()

Notifies that the entire queue has been changed.

public MediaQueueManager setCurrentItemId (Integer currentItemId)

Sets the current item ID to override in MediaStatus.

public MediaQueueManager setMediaQueueData (MediaQueueData queueData)

Sets the MediaQueueData to override in MediaStatus.

public MediaQueueManager setQueueItems (List<MediaQueueItem> queueItems)

Sets the list of items to override the items in MediaStatus.

public MediaQueueManager setQueueRepeatMode (Integer queueRepeatMode)

Sets the queue repeat mode to override in MediaStatus.

public void setQueueStatusLimit (boolean limitQueueItemsInStatus)

Sets whether to limit the number of queue items to be reported in MediaStatus. The default value is true.

If set to true, the queue items will be limited to the current item and its previous and next items in the MediaStatus. The current item is determined using the current item ID. Make sure you are calling setCurrentItemId(Integer) properly. If the current item ID is not set or no matching item is found, the first 3 items will be returned.