PopcornJS playing sequence, reInitialisePopcorn to update the sequence. There might be a better way of doing this by adding and removing the sequence or updating. to the popcorn instance. unless the popcorn instance needs to be initialised with the sequence.
/*PopcornJS playing sequence - working
http://popcornjs.org/popcorn-docs/modules/#sequence
*/
var sequenceArray = [{
src: "http://solutions.brightcove.com/bcls/assets/videos/Bird_Titmouse.mp4",
in : 3,
out: 6
}, {
src: "http://solutions.brightcove.com/bcls/assets/videos/SeaTurtle.mp4",
in : 10,
out: 15
}, {
src: "http://solutions.brightcove.com/bcls/assets/videos/bumper2.mp4",
in : 1,
out: 3
}];
var sequence;
function instanciatePopcornSq() {
sequence = Popcorn.sequence("videoPreview", sequenceArray);
}
function removePopcornPreview() {
//get popcorn div videoPreview id
var videoElem = document.getElementById('videoPreview');
//remove it
videoElem.parentNode.removeChild(videoElem);
//create new one
videoElem = document.createElement('div');
//with same id
videoElem.id = "videoPreview";
//grab containing div videoPreviewContainer
var videoPreviewContainer = document.getElementById('videoPreviewContainer');
//add it to containing div
videoPreviewContainer.appendChild(videoElem);
//document.body.appendChild(videoPreviewContainer);
}
function reInitialisePopcorn() {
removePopcornPreview();
instanciatePopcornSq();
}
//play button
var playBtn = document.getElementById('playButton');
playBtn.onclick = function (e) {
reInitialisePopcorn();
sequence.play();
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.