I am trying to write a Javascript snippet that switches between two timer videos (don't ask). Even worse, each video should start at a specific location (about ten seconds, and again, don't ask.)
I have the basics based on using the YUI Async library to trigger periodic video switching:
YUI().use('async-queue', function (Y) {
var cumulativeTime = 0;
var q = new Y.AsyncQueue()
for (var x = 0; x < settings.length; x++) {
cumulativeTime = cumulativeTime + (settings[x].step * 1000)
q.add( {
fn: runVideo,
args: settings[x].mainWindow,
timeout: cumulativeTime
})
}
q.run()
});
So far so good. The problem is that I cannot get the video to start in ten seconds.
I use this code for this:
function runVideo(videoToPlay) {
console.log('We are going to play -> ' + videoToPlay)
var video = document.getElementById('mainWindow')
video.src = '/video?id=' + videoToPlay
video.addEventListener('loadedmetadata', function() {
this.currentTime = 10
this.play();
})
}
, this.currentTime , . Chrome ( Google Storage Google App Engine), , .
- , , ?
.