onPlayerReady = (player, options) => {
  player.addClass('vjs-mobile-ui');

  if (options.touchControls.disableOnEnd || typeof player.endscreen === 'function') {
    player.addClass('vjs-mobile-ui-disable-end');
  }

  if (
    options.fullscreen.iOS &&
    videojs.browser.IS_IOS &&
    videojs.browser.IOS_VERSION > 9 &&
    !player.el_.ownerDocument.querySelector('.bc-iframe')
  ) {
    player.tech_.el_.setAttribute('playsinline', 'playsinline');
    player.tech_.supportsFullScreen = function() {
      return false;
    };
  }

  const controlBar = player.getChild('ControlBar');

  // Insert before the ControlBar:
  const controlBarIdx = player.children_.indexOf(controlBar);
  player.addChild('touchOverlay', options.touchControls, controlBarIdx);

  // Make the TouchOverlay the new parent of the ControlBar.
  // This allows the ControlBar to listen to the same classes as TouchOverlay.
  player.removeChild(controlBar);
  const touchOverlay = player.getChild('touchOverlay');
  touchOverlay.addChild(controlBar);

  // Tweak controlBar to Mobile style:
  controlBar.removeChild('PlayToggle'); // Use Overlay's instead.

  let locked = false;

  const rotationHandler = () => {
    const currentAngle = angle();

    if (currentAngle === 90 || currentAngle === 270 || currentAngle === -90) {
      if (player.paused() === false) {
        player.requestFullscreen();
        if (options.fullscreen.lockOnRotate && screen.orientation && screen.orientation.lock) {
          screen.orientation
            .lock('landscape')
            .then(() => {
              locked = true;
            })
            .catch(() => {
              videojs.log('orientation lock not allowed');
            });
        }
      }
    }
    if (currentAngle === 0 || currentAngle === 180) {
      if (player.isFullscreen()) {
        player.exitFullscreen();
      }
    }
  };

  if (videojs.browser.IS_IOS) {
    window.addEventListener('orientationchange', rotationHandler);
  } else {
    // addEventListener('orientationchange') is not a user interaction on Android
    screen.orientation.onchange = rotationHandler;
  }

  player.on('ended', _ => {
    if (locked === true) {
      screen.orientation.unlock();
      locked = false;
    }
  });
}
Add UI and event listeners

@function onPlayerReady
@param    {Player} player
          A Video.js player object.

@param    {Object} [options={}]
          A plain object containing options for the plugin.