Queuing¶
PRESTOplay exposes queue APIs on both the receiver and sender, so you can implement custom playlist behavior based on Google Cast queuing.
Receiver queue initialization¶
PRESTOplay implements a basic Queue. Initialize the queue on
the receiver side by calling Receiver.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 or extend
cast.framework.QueueBase
for custom queue lifecycle behavior. Refer to the
CAF custom queue docs
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.
Sender integrations¶
Web SDK sender¶
CastProxy can forward queue commands to the receiver:
CastProxy.queueAddItemsappends 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.queueNextItemandCastProxy.queuePreviousItemnavigate forward and backward through the queue.
Basic queue usage:
const player = new clpp.Player('video', ...);
const proxy = new clpp.cast.CastProxy(player, '<your_receiver_app_id>');
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',
},
},
],
});