Free javascript Hosting


adlec-chan2-day1.js

Uploaded on Nov 05 2021 15:46 by Conrad.Collins

videojs.registerPlugin('adlec_chan2_day1_test', function() {

var myPlayer,
myPlayerEl = document.getElementById("myPlayerID");
myPlayerEl.setAttribute('data-account', intro_id);
myPlayerEl.setAttribute('data-player', 'default');

// Setting the video player options
var options = {
controlBar: {
playToggle: false, // Play&pause button in the video controlbar is removed
durationDisplay: false, // Duration display in the video controlbar is removed
progressControl: false, // Progress bar in the video controlbar is removed
currentTimeDisplay: false, // Current time display in the video controlbar is removed
timeDivider: false, // Time divider in the video controlbar is removed
pictureInPictureToggle: false, // Picture in picture toggle in the video controlbar is removed
},
disablePictureInPicture: true,

};


// Change to morning session video
function changeVideo(video_id, time){
myPlayerEl.setAttribute('data-video-id', video_id);
playVideo();
myPlayer.catalog.getVideo(video_id, function(error,video){
myPlayer.catalog.load (video);
});
myPlayer.currentTime(time); //Uses brightcove API to set the current time on the video to be the time calculated
myPlayer.loop(false);

myPlayer.on("ended",function(){
select_video();
});
}

// Function to play a video - initializes the player, disables clicking, plays the video muted
function playVideo(){
myPlayer = bc(myPlayerEl,options);
myPlayer.el_.firstChild.style.pointerEvents = 'none'; // Disables playing&pausing by clicking on the video
myPlayer.one('loadedmetadata',function(){
myPlayer.muted(true);
myPlayer.play();
});
myPlayer.on('pause', function() {
myPlayer.play();
});
}

// Session times
var startTime_morning_keynotes = new Date('Fri Nov 05 2021 09:15:00 GMT+0000 (Irish Standard Time)'); // Start of Morning Keynotes
var startTime_break1 = new Date('Fri Nov 05 2021 10:30:00 GMT+0000 (Irish Standard Time)'); // Start of Break 1
var startTime_morning = new Date('Fri Nov 05 2021 11:00:00 GMT+0000 (Irish Standard Time)'); // Start of Morning Session
var startTime_lunch = new Date('Fri Nov 05 2021 12:30:00 GMT+0000 (Irish Standard Time)'); // Start of lunch
var startTime_demo = new Date('Fri Nov 05 2021 13:30:00 GMT+0000 (Irish Standard Time)'); // Start of demo Session
var startTime_afternoon = new Date('Fri Nov 05 2021 14:00:00 GMT+0000 (Irish Standard Time)'); // Start of afternoon Session
var startTime_break2 = new Date('Fri Nov 05 2021 15:30:00 GMT+0000 (Irish Standard Time)'); // Start of Break 2
var startTime_evening = new Date('Fri Nov 05 2021 16:00:00 GMT+0000 (Irish Standard Time)'); // Start of evening Session
var startTime_innovation_award = new Date('Wed Nov 04 2021 17:00:00 GMT+0000 (Irish Standard Time)'); // Start of innovation award Session
var startTime_end_day = new Date('Fri Nov 05 2021 17:30:00 GMT+0000 (Irish Standard Time)'); // Start of end day


//player ids
var goto_chan_1_id = "6206337090001";
var intro_id = "6206337090001";
var morning_id = "6206012404001";
var interlude1_id = "6206810963001";
var afternoon_id = "6206011907001";
var evening_id = "6206012404001";

function select_video(){
var currentTime = Date.now(); // Current time (for the user)

if (currentTime<=startTime_morning_keynotes) {
console.log("Before Event");
changeVideo(intro_id, 0);
}
else if (currentTime>=startTime_morning_keynotes & currentTime<=startTime_break1){
console.log("Morning Keynotes");
changeVideo(goto_chan_1_id, 0);
}
else if (currentTime>=startTime_break1 & currentTime<=startTime_morning){
console.log("Break 1");
changeVideo(interlude1_id, 0);
}
else if (currentTime>=startTime_morning & currentTime<=startTime_lunch){
console.log("Morning Session");
var time_diff = (currentTime - startTime_morning)/1000; // Time difference for morning session
changeVideo(morning_id, time_diff);
}
else if (currentTime>=startTime_lunch & currentTime<=startTime_demo){
console.log("Lunch");
changeVideo(interlude1_id, 0);
}
else if (currentTime>=startTime_demo & currentTime<=startTime_afternoon){
console.log("Demo");
changeVideo(goto_chan_1_id, 0);
}
else if (currentTime>=startTime_afternoon & currentTime<=startTime_break2){
console.log("Afternoon Session");
var time_diff = (currentTime - startTime_afternoon)/1000; // Time difference for afternoon session
changeVideo(afternoon_id, time_diff);
}
else if (currentTime>=startTime_break2 & currentTime<=startTime_evening){
console.log("Break 2");
changeVideo(interlude1_id, 0);
}
else if (currentTime>=startTime_evening & currentTime<=startTime_innovation_award){
var time_diff = (currentTime - startTime_evening)/1000; // Time difference for evening session
changeVideo(evening_id, time_diff);
}
else if (currentTime>=startTime_innovation_award & currentTime<=startTime_end_day){
console.log("Innovation Award Session");
changeVideo(goto_chan_1_id, time_diff);
}
else if (currentTime>=startTime_end_day){
console.log("End day");
changeVideo(interlude1_id, time_diff);
}
}

select_video();

});

Back to list