Fetches a window of items using the specified itemID as reference. This
method is called by MediaManager when it needs more queue items, often
stemming from a sender request. If either nextCount or prevCount are
set, fetchItems will only return items after or before the reference
item. If both nextCount and prevCount are set, a window of items
including itemId will be returned.
Initializes the queue with requestData. Called when the receiver
gets a new cast.framework.messages.Command.LOAD request. If this returns or
resolves to null, the default queueing implementation will create a queue
based on queueData.items or on the single media item in the LOAD
request data.
Sets the current item to itemId. Called by MediaManager
when it changes the currently-playing item.
Parameter
itemId
number
The unique ID for the item.
onItemsInserted
onItemsInserted(items, insertBefore)
A callback that indicates that the following items have been inserted into
the receiver queue in this session. A cloud-based implementation might
update its queue based on this new information.
ID of the item that was located
immediately after the inserted list. If the ID is not provided, the
inserted list was appended to the end of the queue.
onItemsRemoved
onItemsRemoved(itemIds)
A callback that indicates that the following items have been removed from
the receiver queue in this session. A cloud-based implementation might
update its queue based on this new information.
Parameter
itemIds
Array of number
The IDs of the items that were removed.
Value must not be null.
onItemsReordered
onItemsReordered(items, insertBefore)
A callback that indicates that the following items have been reordered.
ID of the item that is located
immediately after the reordered list. If insertBefore is not provided,
the reordered list will be appended to the end of the queue.
[null,null,["Last updated 2024-09-18 UTC."],[[["\u003cp\u003e\u003ccode\u003eQueueBase\u003c/code\u003e provides a foundational structure for managing media queues within the Cast framework.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to initialize, fetch, and manipulate queue items, including shuffling and unshuffling.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can extend this base class to implement custom queueing logic for their Cast receiver applications.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eQueueBase\u003c/code\u003e interacts with \u003ccode\u003eMediaManager\u003c/code\u003e to handle queue updates and playback transitions.\u003c/p\u003e\n"],["\u003cp\u003eCallbacks are provided to inform developers about queue modifications like insertions, removals, and reordering.\u003c/p\u003e\n"]]],["The `QueueBase` class manages a media queue, fetching, initializing, and modifying items. Key actions include `fetchItems` to retrieve a range of items based on a reference ID, `initialize` to set up the queue upon a load request, and `nextItems`/`prevItems` to get items following or preceding a given item. Other methods handle updates like `onItemsInserted`, `onItemsRemoved`, `onItemsReordered`, and also manage playback order using `shuffle` and `unshuffle`. The `onCurrentItemIdChanged` method is called when an item is playing.\n"],null,["# Class: QueueBase\n\ncast.[framework](/cast/docs/reference/web_receiver/cast.framework).QueueBase\n============================================================================\n\nclass static\n\nBase implementation of a queue.\n\nConstructor\n-----------\n\n### QueueBase\n\nnew\nQueueBase()\n\nMethods\n-------\n\n### fetchItems\n\nfetchItems(itemId, nextCount, prevCount) returns (non-null Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) or non-null Promise containing non-null Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem))\n\nFetches a window of items using the specified `itemID` as reference. This\nmethod is called by `MediaManager` when it needs more queue items, often\nstemming from a sender request. If either `nextCount` or `prevCount` are\nset, `fetchItems` will only return items after or before the reference\nitem. If both `nextCount` and `prevCount` are set, a window of items\nincluding `itemId` will be returned.\n\n| #### Parameter ||\n|-----------|---------------------------------------------------|\n| itemId | number The ID of the reference item. |\n| nextCount | number Number of items after the reference item. |\n| prevCount | number Number of items before the reference item. |\n\nReturns\n\n: `(non-null Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)` or non-null Promise containing non-null Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)`)`\n\n### initialize\n\ninitialize(requestData) returns ([cast.framework.messages.QueueData](/cast/docs/reference/web_receiver/cast.framework.messages.QueueData) or non-null Promise containing nullable [cast.framework.messages.QueueData](/cast/docs/reference/web_receiver/cast.framework.messages.QueueData))\n\nInitializes the queue with `requestData`. Called when the receiver\ngets a new `cast.framework.messages.Command.LOAD` request. If this returns or\nresolves to `null`, the default queueing implementation will create a queue\nbased on `queueData.items` or on the single media item in the `LOAD`\nrequest data.\n\n| #### Parameter ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| requestData | [cast.framework.messages.LoadRequestData](/cast/docs/reference/web_receiver/cast.framework.messages.LoadRequestData) Value must not be null. |\n\nReturns\n\n: `(nullable `[cast.framework.messages.QueueData](/cast/docs/reference/web_receiver/cast.framework.messages.QueueData)` or non-null Promise containing nullable `[cast.framework.messages.QueueData](/cast/docs/reference/web_receiver/cast.framework.messages.QueueData)`)`\n\n### nextItems\n\nnextItems(itemId) returns (nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) or non-null Promise containing nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem))\n\nReturns all items in the queue following `itemID`. This is called by\n`MediaManager`.\n\n| #### Parameter ||\n|--------|-----------------------------------------------|\n| itemId | Optional number The ID of the reference item. |\n\nReturns\n\n: `(nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)` or non-null Promise containing nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)`)`\n\n### onCurrentItemIdChanged\n\nonCurrentItemIdChanged(itemId)\n\nSets the current item to `itemId`. Called by `MediaManager`\nwhen it changes the currently-playing item.\n\n| #### Parameter ||\n|--------|------------------------------------|\n| itemId | number The unique ID for the item. |\n\n### onItemsInserted\n\nonItemsInserted(items, insertBefore)\n\nA callback that indicates that the following items have been inserted into\nthe receiver queue in this session. A cloud-based implementation might\nupdate its queue based on this new information.\n\n| #### Parameter ||\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| items | Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) The items that were inserted. Value must not be null. |\n| insertBefore | Optional number ID of the item that was located immediately after the inserted list. If the ID is not provided, the inserted list was appended to the end of the queue. |\n\n### onItemsRemoved\n\nonItemsRemoved(itemIds)\n\nA callback that indicates that the following items have been removed from\nthe receiver queue in this session. A cloud-based implementation might\nupdate its queue based on this new information.\n\n| #### Parameter ||\n|---------|---------------------------------------------------------------------------------|\n| itemIds | Array of number The IDs of the items that were removed. Value must not be null. |\n\n### onItemsReordered\n\nonItemsReordered(items, insertBefore)\n\nA callback that indicates that the following items have been reordered.\n\n| #### Parameter ||\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| items | Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) The IDs of the items that were reordered. Value must not be null. |\n| insertBefore | Optional number ID of the item that is located immediately after the reordered list. If `insertBefore` is not provided, the reordered list will be appended to the end of the queue. |\n\nSee also\n: [cast.framework.messages.QueueReorderRequestData#itemIds](/cast/docs/reference/web_receiver/cast.framework.messages.QueueReorderRequestData#itemIds) for more details.\n\n### prevItems\n\nprevItems(itemId) returns (nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) or non-null Promise containing nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem))\n\nReturns all items before `itemID`. This is called by `MediaManager`.\n\n| #### Parameter ||\n|--------|-----------------------------------------------|\n| itemId | Optional number The ID of the reference item. |\n\nReturns\n\n: `(nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)` or non-null Promise containing nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)`)`\n\n### shuffle\n\nshuffle() returns (nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) or non-null Promise containing nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem))\n\nShuffles the queue and returns new queue items. Returns `null` if the\noperation is not supported.\n\nReturns\n\n: `(nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)` or non-null Promise containing nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)`)`\n\n### unshuffle\n\nunshuffle() returns (nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem) or non-null Promise containing nullable Array of non-null [cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem))\n\nUnshuffles the queue and returns new queue items. Returns `null` if the\noperation is not supported.\n\nReturns\n\n: `(nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)` or non-null Promise containing nullable Array of non-null `[cast.framework.messages.QueueItem](/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem)`)`"]]