Casting from video playlist

Chromecast plugin - Casting from video playlist

Player, plugins and playlist setup for Casting video through Chromecast plugin almost does not differ from default player and playlist setup described on dedicated tutorial page.
If only playlist video is of proper format, it will be available to cast, including autoadvance playback of playlist videos. Playlist item title will be automatically populated to casting device. You can also define chromecast subtitle, or even define it for each of available mp4 qualities.
// Load videojs nuevo and chromecasty plugins on website

<script src="//www.domain.com/videojs/video.min.js"></script>
<script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
<script src="//www.domain.com/videojs/nuevo.min.js"></script>
<script src="//www.domain.com/videojs/plugins/videojs-chromecast.min.js"></script>

// Setup video element on website

<video id="video_1" class="video-js vjs-fluid" controls width="640" height="360" poster="//www.domain.com/poster.jpg">

// Initialize player, nuevo plugin with playlist options

<script>
   // Optionally set nuevo plugin options
   var options = {option1:'option', option2: 'option2'};
   var player=videojs("video_1");
   player.nuevo( options);
   player.chromecast();

// Setup playlist media files
   player.playlist([{
	sources: [{
	    src: 'http://domain.com/video1.mp4',
	    type: 'video/mp4'
	  }],
	  title: 'video 1 title',
	  subtitle: 'video 1 subtitle',
	  thumb: 'http://domain.com/video1_thumb.jpg', // Suggested size 80x45 px
	  poster: 'https://domain.com/video1_poster.jpg',
	  duration: '03:40',
	}, {
	  // Multiple resolutions mp4 video
	  sources: [{
	    src: 'http://domain.com/video2_720p.mp4',
	    type: 'video/mp4', res: '720', label: '720p'
	  }, {
	    src: 'http://domain.com/video2_360p.mp4',
	    type: 'video/mp4', res: '360', label: '360p', default
	  }, {
	    src: 'http://domain.com/video2_240p.mp4',
	    type: 'video/mp4', res: '240', label: '240p'
	  }],
	  title: 'video 2 title',
	  subtitle: 'video 2 subtitle',
	  thumb: 'http://domain.com/video2_thumb.jpg', 
	  poster: 'https://domain.com/video1_poster.jpg',
	  duration: '05:20',
	  slideImage: 'http://domain.com/video2_slide.jpg', // Optional progressbar thumbs slide image
	}, {
	  // HLS m3u8 playlist file
	  sources: [{
	    src: 'http://domain.com/playlist.m3u8',
	    type: 'application/x-mpegURL'
	  }],
	  title: 'video 3 title',
	  subtitle: 'video3 subtitle',
	  thumb: 'http://domain.com/video4_thumb.jpg',
	  poster: 'https://domain.com/video1_poster.jpg',
	  duration: '03:40',
	}
	]);
</script>
	

As you can see the only difference in player with playlist setup code is loading chromecast required scripts, initializing chromecast plugin and optionaly, adding subtitle for each playlist's video item.
Playlist item attributes like subtitle or poster are not required, but certainly makes player design and chromecast display more attractive and professional.