Skip to content

Commit

Permalink
Add aspect ratio controls to player. (jellyfin#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwalton3 authored and zjeffer committed Jun 14, 2023
1 parent 90cf5f4 commit 58cecfb
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions native/mpvVideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@
* @private
*/
static getSupportedFeatures() {
return ['PlaybackRate'];
return ['PlaybackRate', 'SetAspectRatio'];
}

supports(feature) {
Expand Down Expand Up @@ -745,20 +745,6 @@
return this._muted;
}

setAspectRatio() {
}

getAspectRatio() {
return this._currentAspectRatio || 'auto';
}

getSupportedAspectRatios() {
return [{
name: this.globalize.translate('Auto'),
id: 'auto'
}];
}

togglePictureInPicture() {
}

Expand Down Expand Up @@ -823,6 +809,37 @@
categories: categories
});
}

getSupportedAspectRatios() {
const options = window.jmpInfo.settingsDescriptions.video.find(x => x.key == 'aspect').options;
const current = window.jmpInfo.settings.video.aspect;

const getOptionName = (option) => {
const canTranslate = {
'normal': 'Auto',
'zoom': 'AspectRatioCover',
'stretch': 'AspectRatioFill',
}
const name = option.replace('video.aspect.', '');
return canTranslate[name]
? this.globalize.translate(canTranslate[name])
: name;
}

return options.map(x => ({
id: x.value,
name: getOptionName(x.title),
selected: x.value == current
}));
}

getAspectRatio() {
return window.jmpInfo.settings.video.aspect;
}

setAspectRatio(value) {
window.jmpInfo.settings.video.aspect = value;
}
}
/* eslint-enable indent */

Expand Down

0 comments on commit 58cecfb

Please sign in to comment.