videojs-resolution-switcher
videojs-resolution-switcher copied to clipboard
Change resolution when going fullscreen, based on screen resolution
Is the topic possible with this plugin?
This is pretty trivial. I don't think it would be very beneficial to add it to this repo.
If you want to implement it in your code, this should get you started:
var vjsPlayer = videojs.getComponent('Player');
videojs.registerComponent('Player', videojs.extend(vjsPlayer, {
constructor: function (videoElem, options, readyCallback) {
vjsPlayer.call(this, videoElem, options, readyCallback);
this.on('resolutionchange', this.handleResolutionChange.bind(this));
},
handleResolutionChange: function () {
var oResolution = this.currentResolution();
var lblResolution = oResolution.label;
var oAllSources = this.getGroupedSrc();
//Do work here. Get your window dimensions from window.screenWidth and all that.
//Decide which wource you want to use based on the dimensions.
this.currentResolution(/*Then pass in your target resolution*/);
},
}));