Home

Playlists with event listeners

Let's change the background colour of the body everytime a video finishes.

      
        var myVideo = new Player({
          playlist: '1u-niluB8HI, cHHLHGNpCSA, 2-MBfn8XjIU, pB-5XG-DbAA, ktvTqknDobU',
          placement: '.example-div',
          autoPlay: 1,
          onStateChange: {
            ended: function() {
              var body = document.querySelector('body');
              body.style.backgroundColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
            }
          }
        });
      
    
Back to Playlists