Home

Custom Events with API

Hooking into the `_onPlayerReady` event allows us to notify the user the video is ready

Video Not Ready

On state change listener

Using the `onStateChange` param, we can interact with the advert based upon what the video is doing.

Default state

      
        var myVideo = new Player({
          videoId: 'pPWKJTo2GXw',
          placement: '.container',
          mute: 1,
          onStateChange: {
            playing: function() {
              // Some code here...
            },
            paused: function() {
              // Some code here...
            },
            ended: function() {
              // Some code here...
            }
          },
          _onPlayerReady: function() {
            var heading = document.querySelector('.heading');
            heading.className += ' ready';
          }
        });