2

I'm trying to make something that will quickly load a second video to make it appear is if the two videos were concatenated into one (because depending on key inputs, one video could lead to two choices depending on if the user hits the correct key)

Right now the basic function I'm using is:

function play(first, second){
    var video = document.getElementById("media")

    video.setAttribute("src", first)
    video.load()
    video.play()

    setTimeout(function(){
        video.setAttribute("src", second)
        video.load()
        video.play()
    }, 2000)
}

Right now it's got about a second of lag so that it doesn't appear as if the two videos are one. Any ideas on how to fix this?

David
  • 208,112
  • 36
  • 198
  • 279
Riveascore
  • 1,724
  • 4
  • 26
  • 46
  • Where are you copying this from? remove the line-numbers please.... – Naftali Dec 15 '11 at 17:05
  • You could preload the 2nd video. Also you'd better use `video.onended=function(){...}` instead of setTimout; – Gerben Dec 15 '11 at 17:38
  • I agree on the use of video.onended as a more robust way of switching sources. also if you have problems using the preload="auto" to get enough of the video loaded you could use the solution in http://stackoverflow.com/questions/14344690/why-dont-all-videos-load-on-page-in-chrome to preload via ajax into a blob – Offbeatmammal Jan 21 '13 at 17:30
  • Also... have you thought about having two video elements (one visible, one not, both with preload="auto") and toggle visibility between the two – Offbeatmammal Mar 11 '13 at 16:41

0 Answers0