A
A
ash_12014-10-19 17:42:14
JavaScript
ash_1, 2014-10-19 17:42:14

Track the esc event when exiting the full screen video mode, how to do?

using the videojs.com library, I
made my own player, when you click on the button, the full-screen mode changes the length of the playback track, when you click again, it exits the full-screen mode and the track length becomes the same.
Pressing esc exits full screen mode, but the track length remains the same as for full screen mode. So how do you track the esc event?

I used this code, for some reason it works outside of full-screen mode, and when viewed in full-screen mode, only the transition to normal video mode function works.

var bar = true;
function resizepro() {
  $('.video-js').click(function() {
    $('.vjs-fullscreen-control').addClass('dlinabara');
    $('.dlinabara').click(function() {
      if(bar) {
        $('.vjs-progress-control').css('width','78%');
        $('.vjs-current-time').css('margin','-1px 10px 0px 80%');
        bar = false;
      }
      else{
        $('.vjs-progress-control').css('width','375px');
        $('.vjs-current-time').css('margin','-1px 10px 0px 387px');
        bar = true;
        
      }
    });
    $(document).keydown(function() {
      $('.vjs-progress-control').css('width','375px');
      $('.vjs-current-time').css('margin','-1px 10px 0px 387px');
      bar = true;
    });
  });
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin, 2014-10-31
@unity_ultra_hardcore

It's probably better to use the video.js API and subscribe to the fullscreenchange event , in the handler of which it is already necessary to change the track width.
I haven't worked with videojs, but the event subscription code looks something like this:

videojs("video-selector").ready(function() {
    this.on("fullscreenchange", function() {
        // код изменения ширины дорожки
    });
});

Perhaps there are other ways, but the meaning does not change: you need to subscribe to the event and react to it, and not try to read the encapsulated state of the object from the outside.
List of all videojs events

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question