Skip to content

Commit

Permalink
Add aspect ratio controls to player. (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwalton3 committed Mar 12, 2023
1 parent 43e068c commit 953ee16
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 953ee16

Please sign in to comment.