Queuing ******* PRESTOplay for Web Apps exposes queue APIs on both the receiver and sender, so you can implement custom playlist behavior based on Google Cast queuing (https://developers.google.com/cast/docs/web_receiver/queueing). Code samples: * Chromecast receiver (https://raw.githubusercontent.com/castlabs/prestoplay-web-code-samples/refs/heads/main/examples/cast/chromecast_receiver.js): registers the queue and reads it through the queue manager. Receiver queue initialization ============================= PRESTOplay for Web Apps implements a basic "Queue" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.Queue.md). Initialize the queue on the receiver side by calling "Receiver.setQueue" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.Receiver.md#setQueue) before "receiver.start()", so the Cast Application Framework (CAF) has the queue registered before it accepts sender sessions: const player = new clpp.Player('video'); const receiver = clpp.cast.Receiver.getInstance(); const queue = clpp.cast.createCastQueue(); receiver.init(player); receiver.setQueue(queue); receiver.start(); Custom queue ============ Use "cast.createCastQueue" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.md#createCastQueue) or extend "cast.framework.QueueBase" (https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.QueueBase) for custom queue lifecycle behavior. Refer to the CAF custom queue docs (https://developers.google.com/cast/docs/web_receiver/queueing#custom_queue) for implementation reference. class CustomQueue extends cast.framework.QueueBase { // ... } const player = new clpp.Player('video'); const receiver = clpp.cast.Receiver.getInstance(); const queue = new CustomQueue(); receiver.init(player); receiver.setQueue(queue); receiver.start(); Receiver queue management ========================= Once the queue is registered, call "clpp.cast.Receiver.getInstance().getQueueManager()" to get the CAF queue manager and use its APIs (https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.QueueManager). Sender integrations =================== PRESTOplay for Web Apps sender ------------------------------ "CastProxy" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.CastProxy.md) can forward queue commands to the receiver: * "CastProxy.queueAddItems" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.CastProxy.md#queueAddItems) appends new items to the end of the queue. castProxy.queueAddItems([ { media: { contentId: 'https://demo.cf.castlabs.com/media/prestodash/Manifest.mpd', contentType: 'application/dash+xml', }, }, { media: { contentId: 'https://demo.cf.castlabs.com/media/TOS/abr/Manifest_clean_sizes.mpd', contentType: 'application/dash+xml', }, }, ]); * "CastProxy.queueNextItem" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.CastProxy.md#queueNextItem) and "CastProxy.queuePreviousItem" (https://players.castlabs.com/web/latest/docs/api/clpp.cast.CastProxy.md#queuePreviousItem) navigate forward and backward through the queue. Basic queue usage: const player = new clpp.Player('video', ...); const proxy = new clpp.cast.CastProxy(player, ''); player.open({ source: 'https://demo.cf.castlabs.com/media/prestodash/Manifest.mpd', type: 'application/dash+xml', drmProtected: false, }); // Add queue items right after the casting session starts player.on(clpp.events.CAST_STATUS_CHANGED, () => { if (proxy.isCasting()) { proxy.queueAddItems([ { media: { contentId: 'https://demo.cf.castlabs.com/media/prestodash/Manifest.mpd', contentType: 'application/dash+xml', }, }, { media: { contentId: 'https://demo.cf.castlabs.com/media/TOS/abr/Manifest_clean_sizes.mpd', contentType: 'application/dash+xml', }, }, ]); } }); Generic senders via custom messages ----------------------------------- Any sender can interact with the custom queue through CAF messages: const session = cast.framework.CastContext.getInstance().getCurrentSession(); session.sendMessage('urn:x-cast:com.google.cast.media', { type: 'QUEUE_INSERT', requestId, mediaSessionId: session.getMediaSession().mediaSessionId, items: [ { media: { contentId: 'https://demo.cf.castlabs.com/media/TOS/abr/Manifest_clean_sizes.mpd', contentType: 'application/dash+xml', }, }, ], });