Search code examples
javascriptpopcornjs

Periodic event in popcorn.js


How can popcorn.js be configured to emit event every time there's update in time of the video? Should I just use the timeupdate event of the video element then?

Currently, I could only setup event at a specific start time:

var p = Popcorn( "#video" )
      // play the video
      .play()
      // set the volume to zero
      .volume( 0 )
      .code({
        start: 1,
        end: 3,
        onStart: function( options ) {         
          document.getElementById( "test1" ).innerHTML = "Yes";
        },
        onEnd: function( options ) {
          document.getElementById( "test1" ).innerHTML = "No";
        }
     })

Solution

  • From the official Docs it says you capture event everytime the player time is updated

    var pop = Popcorn("#video");
    
    pop.on("timeupdate", function( e ) {
        console.log( "timeupdate fired!");
    });
    
    pop.play();