Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility fix VideoJs 7+ (handleTechSeeked_, currentResolution, change label, hidden) #129

Open
BaNru opened this issue Apr 3, 2019 · 6 comments

Comments

@BaNru
Copy link

BaNru commented Apr 3, 2019

VideoJS 7+
videojs-resolution-switcher - 2015-7-26
Modified by Pierre Kraft and Derk-Jan Hartman

Error after switching quality

VIDEOJS: ERROR: TypeError: player.play(...).handleTechSeeked_ is not a function
at Player. (videojs-resolution-switcher.js:184)

This is probably due to the exclusion of the flash from the kernel.
https://blog.videojs.com/video-js-removes-flash-from-core-player/

My fix
Find strings

player
  .setSourcesSanitized(sources, label, customSourcePicker || settings.customSourcePicker)
  .one(handleSeekEvent, function() {
    player.currentTime(currentTime);
    player.handleTechSeeked_();
    if(!isPaused){
      // Start playing and hide loadingSpinner (flash issue ?)
      player.play().handleTechSeeked_();
    }
    player.trigger('resolutionchange');
  });

And replace with if you do NOT need FLASH support

player
  .setSourcesSanitized(sources, label, customSourcePicker || settings.customSourcePicker)
  .one(handleSeekEvent, function() {
    player.currentTime(currentTime);
    if(!isPaused){
      player.play();
    }
    player.trigger('resolutionchange');
  });

Or replace if you need FLASH support

player
  .setSourcesSanitized(sources, label, customSourcePicker || settings.customSourcePicker)
  .one(handleSeekEvent, function() {
    player.currentTime(currentTime);
    if(player.handleTechSeeked_()){
      player.handleTechSeeked_();
      if(!isPaused){
        // Start playing and hide loadingSpinner (flash issue ?)
        player.play().handleTechSeeked_();
      }
    }else{
      if(!isPaused){
        player.play();
      }
    }
    player.trigger('resolutionchange');
  });
@BaNru
Copy link
Author

BaNru commented Apr 4, 2019

next error

TypeError: Cannot read property 'currentResolution' of null

Find

ResolutionMenuItem.prototype.update = function(){
  var selection = this.player_.currentResolution();
  this.selected(this.options_.label === selection.label);
};

Replace

ResolutionMenuItem.prototype.update = function(){
  if(!this.player_)return false;
  var selection = this.player_.currentResolution();
  this.selected(this.options_.label === selection.label);
};

@BaNru
Copy link
Author

BaNru commented Apr 4, 2019

next error: label does not change after changing quality
The decision is very bad. I did not find another option to access the button to change the values. But it works.

Add last string

ResolutionMenuItem.prototype.update = function(){
      if(!this.player_)return false;
      var selection = this.player_.currentResolution();
      this.selected(this.options_.label === selection.label);
      this.player_.controlBar.resolutionSwitcher.lastElementChild.textContent = selection.label;
    };

@BaNru
Copy link
Author

BaNru commented Apr 4, 2019

next error: the menu is blocked (hidden) after the first choice of quality.
The problem appeared after the update release VIDEO v7.4.0

vjs-lock-showing class gets removed from menu when no longer hovering on menu-button. (#5465) (
58f638e), closes #1690

Added hiding / showing items on rows #336 and #358, after which the menu started to block.

Decision
The solution is similar to the previous one, not the best

Add new last string

ResolutionMenuItem.prototype.update = function(){
  if(!this.player_)return false;
  var selection = this.player_.currentResolution();
  this.selected(this.options_.label === selection.label);
  this.player_.controlBar.resolutionSwitcher.lastElementChild.textContent = selection.label;
  this.player_.controlBar.resolutionSwitcher.children[1].classList.remove('vjs-hidden');
};

After these edits, errors were no longer seen. The plugin works well with the VideoJS 7+

PS Sorry for my googletranslate

PPS https://github.com/BaNru/videojs-resolution-switcher/blob/master/lib/videojs-resolution-switcher.js

BaNru added a commit to BaNru/videojs-resolution-switcher that referenced this issue Apr 4, 2019
1/4 compatibility fix VideoJs 7+

Error after switching quality
> VIDEOJS: ERROR: TypeError: player.play(...).handleTechSeeked_ is not a function at Player. (videojs-resolution-switcher.js:184)
This is probably due to the exclusion of the flash from the kernel.
https://blog.videojs.com/video-js-removes-flash-from-core-player/

kmoskwiak#129 (comment)
BaNru added a commit to BaNru/videojs-resolution-switcher that referenced this issue Apr 4, 2019
3/4 compatibility fix VideoJs 7+

The decision is very bad. I did not find another option to access the button to change the values. But it works.

kmoskwiak#129 (comment)
BaNru added a commit to BaNru/videojs-resolution-switcher that referenced this issue Apr 4, 2019
4/4 compatibility fix VideoJs 7+

The problem appeared after the update release VIDEO v7.4.0

> vjs-lock-showing class gets removed from menu when no longer hovering on menu-button. (#5465) (58f638e), closes #1690

Added hiding / showing items on rows #336 and #358, after which the menu started to block.

The solution is similar to the previous one, not the best

kmoskwiak#129 (comment)
@BaNru BaNru changed the title TypeError: player.play(...).handleTechSeeked_ is not a function Compatibility fix VideoJs 7+ (handleTechSeeked_, currentResolution, change label, hidden) Apr 4, 2019
datagutt added a commit to GuacLive/videojs-resolution-switcher that referenced this issue Jun 18, 2019
@pythonsan
Copy link

Very Good :-)

@masarinetwork
Copy link

masarinetwork commented Sep 27, 2019

My Case not work because:

// register the plugin
videojs.registerPlugin('videoJsResolutionSwitcher', videoJsResolutionSwitcher);
})(window, videojs.default);

Change to

// register the plugin
videojs.registerPlugin('videoJsResolutionSwitcher', videoJsResolutionSwitcher);
})(window, videojs);

On line 69

videojs.addClass(staticLabel, 'vjs-menu-icon');

Change to

videojs.dom.addClass(staticLabel, 'vjs-menu-icon');

@JasonCheng58
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants