demo/dist/demo.js
function newSource(type, init) {
	        // Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
	        if (!(type in types) || !init && type === currentType || !currentType.length && type === types.video) {
	          return;
	        }

	        switch (type) {
	          case types.video:
	            player.source = {
	              type: 'video',
	              title: 'View From A Blue Moon',
	              sources: [{
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4',
	                type: 'video/mp4',
	                size: 576
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4',
	                type: 'video/mp4',
	                size: 720
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4',
	                type: 'video/mp4',
	                size: 1080
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1440p.mp4',
	                type: 'video/mp4',
	                size: 1440
	              }],
	              poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
	              tracks: [{
	                kind: 'captions',
	                label: 'English',
	                srclang: 'en',
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
	                default: true
	              }, {
	                kind: 'captions',
	                label: 'French',
	                srclang: 'fr',
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt'
	              }]
	            };
	            break;

	          case types.audio:
	            player.source = {
	              type: 'audio',
	              title: 'Kishi Bashi &ndash; &ldquo;It All Began With A Burst&rdquo;',
	              sources: [{
	                src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
	                type: 'audio/mp3'
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
	                type: 'audio/ogg'
	              }]
	            };
	            break;

	          case types.youtube:
	            player.source = {
	              type: 'video',
	              sources: [{
	                src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
	                provider: 'youtube'
	              }]
	            };
	            break;

	          case types.vimeo:
	            player.source = {
	              type: 'video',
	              sources: [{
	                src: 'https://vimeo.com/76979871',
	                provider: 'vimeo'
	              }]
	            };
	            break;

	          default:
	            break;
	        } // Set the current type for next time


	        currentType = type; // Remove active classes

	        Array.from(buttons).forEach(function (button) {
	          return toggleClass(button.parentElement, 'active', false);
	        }); // Set active on parent

	        toggleClass(document.querySelector("[data-source=\"".concat(type, "\"]")), 'active', true); // Show cite

	        Array.from(document.querySelectorAll('.plyr__cite')).forEach(function (cite) {
	          cite.setAttribute('hidden', '');
	        });
	        document.querySelector(".plyr__cite--".concat(type)).removeAttribute('hidden');
	      }
function newSource(type, init) {
	        // Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
	        if (!(type in types) || !init && type === currentType || !currentType.length && type === types.video) {
	          return;
	        }

	        switch (type) {
	          case types.video:
	            player.source = {
	              type: 'video',
	              title: 'View From A Blue Moon',
	              sources: [{
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4',
	                type: 'video/mp4',
	                size: 576
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4',
	                type: 'video/mp4',
	                size: 720
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4',
	                type: 'video/mp4',
	                size: 1080
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1440p.mp4',
	                type: 'video/mp4',
	                size: 1440
	              }],
	              poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
	              tracks: [{
	                kind: 'captions',
	                label: 'English',
	                srclang: 'en',
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
	                default: true
	              }, {
	                kind: 'captions',
	                label: 'French',
	                srclang: 'fr',
	                src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt'
	              }]
	            };
	            break;

	          case types.audio:
	            player.source = {
	              type: 'audio',
	              title: 'Kishi Bashi &ndash; &ldquo;It All Began With A Burst&rdquo;',
	              sources: [{
	                src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
	                type: 'audio/mp3'
	              }, {
	                src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
	                type: 'audio/ogg'
	              }]
	            };
	            break;

	          case types.youtube:
	            player.source = {
	              type: 'video',
	              sources: [{
	                src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
	                provider: 'youtube'
	              }]
	            };
	            break;

	          case types.vimeo:
	            player.source = {
	              type: 'video',
	              sources: [{
	                src: 'https://vimeo.com/76979871',
	                provider: 'vimeo'
	              }]
	            };
	            break;

	          default:
	            break;
	        } // Set the current type for next time


	        currentType = type; // Remove active classes

	        Array.from(buttons).forEach(function (button) {
	          return toggleClass(button.parentElement, 'active', false);
	        }); // Set active on parent

	        toggleClass(document.querySelector("[data-source=\"".concat(type, "\"]")), 'active', true); // Show cite

	        Array.from(document.querySelectorAll('.plyr__cite')).forEach(function (cite) {
	          cite.setAttribute('hidden', '');
	        });
	        document.querySelector(".plyr__cite--".concat(type)).removeAttribute('hidden');
	      }
function newSource ( type , init ) { // Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video if ( ! ( type in types ) || ! init && type === currentType || ! currentType . length && type === types . video ) { return ; } switch ( type ) { case types . video : player . source = { type : 'video' , title : 'View From A Blue Moon' , sources : [ { src : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4' , type : 'video/mp4' , size : 576 } , { src : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4' , type : 'video/mp4' , size : 720 } , { src : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4' , type : 'video/mp4' , size : 1080 } , { src : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1440p.mp4' , type : 'video/mp4' , size : 1440 } ] , poster : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg' , tracks : [ { kind : 'captions' , label : 'English' , srclang : 'en' , src : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt' , default : true } , { kind : 'captions' , label : 'French' , srclang : 'fr' , src : 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt' } ] } ; break ; case types . audio : player . source = { type : 'audio' , title : 'Kishi Bashi &ndash; &ldquo;It All Began With A Burst&rdquo;' , sources : [ { src : 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3' , type : 'audio/mp3' } , { src : 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg' , type : 'audio/ogg' } ] } ; break ; case types . youtube : player . source = { type : 'video' , sources : [ { src : 'https://youtube.com/watch?v=bTqVqk7FSmY' , provider : 'youtube' } ] } ; break ; case types . vimeo : player . source = { type : 'video' , sources : [ { src : 'https://vimeo.com/76979871' , provider : 'vimeo' } ] } ; break ; default : break ; } // Set the current type for next time currentType = type ; // Remove active classes Array . from ( buttons ) . forEach ( function ( button ) { return toggleClass ( button . parentElement , 'active' , false ) ; } ) ; // Set active on parent toggleClass ( document . querySelector ( "[data-source=\"" . concat ( type , "\"]" ) ) , 'active' , true ) ; // Show cite Array . from ( document . querySelectorAll ( '.plyr__cite' ) ) . forEach ( function ( cite ) { cite . setAttribute ( 'hidden' , '' ) ; } ) ; document . querySelector ( ".plyr__cite--" . concat ( type ) ) . removeAttribute ( 'hidden' ) ; }
Set a new source
Set a new source