videojs-resolution-switcher icon indicating copy to clipboard operation
videojs-resolution-switcher copied to clipboard

Change resolution when going fullscreen, based on screen resolution

Open UralZima opened this issue 7 years ago • 1 comments

Is the topic possible with this plugin?

UralZima avatar Mar 01 '17 09:03 UralZima

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*/);
	},
}));

DerekZiemba avatar Mar 02 '17 05:03 DerekZiemba