Demonstrate adding new streams to the Chromecast queue while casting.
function app() {
return {
init() {
//do init stuff here
},
addCastStream(e) {
player.appendSrc({
"title": "Sintel",
"castInfo": {
"title": "Sintel",
"subtitle": "Subtitle",
"images": [
{
"url": "http://192.168.5.25:8000/plugins//videojs/chromecast/images/stills/sintel_still.jpg"
}
]
},
"sources": [{'type': 'video/mp4', 'src': 'https://videos.electroteque.org/bitrate/sintel_2000k.mp4'}]
});
}
}
}
<div class="flex w-full h-auto my-auto">
<video class="video-js vjs-default-skin vjs-fluid " crossorigin="anonymous" controls="" id="addstream"></video>
</div>
<script type="text/javascript">
var player = videojs("addstream", {
"plugins": {
"chromecast": {
"castAppID": "5C78621A"
}
}
});
const playlistPlugin = player.playlistPlugin(player, {});
const PlaylistPluginClass = videojs.getPlugin('playlistPlugin');
const videoList = [
{
"castInfo": {
"images": [
{
"url": "http://192.168.5.25:8000/plugins//videojs/chromecast/images/stills/bbb_still.jpg"
}
],
"subtitle": "Subtitle",
"title": "Big Buck Bunny"
},
"sources": [
{
"src": "https://videos.electroteque.org/bitrate/big_buck_bunny_2000k.mp4",
"type": "video/mp4"
},
{
"src": "https://videos.electroteque.org/bitrate/big_buck_bunny_2000k.ogv",
"type": "video/ogg"
}
]
}
];
const playlist = PlaylistPluginClass.createPlaylistFrom(videoList);
// Plugin methods
playlistPlugin.loadPlaylist(playlist);
player.playlistUi({playOnSelect: true});
playlistPlugin.loadFirstItem();
playlistPlugin.setAutoadvanceDelay(0);
</script>