Cycle mode
This commit is contained in:
parent
65da515854
commit
302f21b477
@ -1,4 +1,5 @@
|
|||||||
enum AspectRatioType {
|
enum AspectRatioType {
|
||||||
|
Cycle = -2,
|
||||||
Initial = -1, // page default
|
Initial = -1, // page default
|
||||||
Reset = 0, // reset to initial
|
Reset = 0, // reset to initial
|
||||||
Automatic = 1, // we want to request automatic aspect ratio detection
|
Automatic = 1, // we want to request automatic aspect ratio detection
|
||||||
|
@ -249,6 +249,23 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
onKeyUp: true,
|
onKeyUp: true,
|
||||||
onKeyDown: false,
|
onKeyDown: false,
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
action: 'set-ar',
|
||||||
|
label: 'Cycle',
|
||||||
|
comment: 'Cycle through crop options',
|
||||||
|
arguments: {
|
||||||
|
type: AspectRatioType.Cycle
|
||||||
|
},
|
||||||
|
shortcut: {
|
||||||
|
key: 'c',
|
||||||
|
code: 'KeyC',
|
||||||
|
ctrlKey: false,
|
||||||
|
metaKey: false,
|
||||||
|
altKey: false,
|
||||||
|
shiftKey: false,
|
||||||
|
onKeyUp: true,
|
||||||
|
onKeyDown: false,
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
action: 'set-ar',
|
action: 'set-ar',
|
||||||
label: '21:9',
|
label: '21:9',
|
||||||
@ -679,6 +696,13 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
show: true,
|
show: true,
|
||||||
path: 'crop'
|
path: 'crop'
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
name: 'Cycle aspect ratio',
|
||||||
|
label: 'Cycle',
|
||||||
|
cmd: [{
|
||||||
|
action: 'set-ar',
|
||||||
|
arg: AspectRatioType.Cycle
|
||||||
|
}]
|
||||||
},{
|
},{
|
||||||
userAdded: true,
|
userAdded: true,
|
||||||
name: 'Set aspect ratio to 16:9',
|
name: 'Set aspect ratio to 16:9',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { IframeData } from './video-data/IframeManager';
|
||||||
import CommsClient, { CommsOrigin } from './comms/CommsClient';
|
import CommsClient, { CommsOrigin } from './comms/CommsClient';
|
||||||
import CommsServer from './comms/CommsServer';
|
import CommsServer from './comms/CommsServer';
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ export default class EventBus {
|
|||||||
window.removeEventListener('message', this.handleIframeMessage);
|
window.removeEventListener('message', this.handleIframeMessage);
|
||||||
}
|
}
|
||||||
private handleIframeMessage(event: any) {
|
private handleIframeMessage(event: any) {
|
||||||
console.log('GOT IFRAME MESSAGE!', event)
|
// console.log('GOT IFRAME MESSAGE!', event)
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
@ -227,7 +227,7 @@ class VideoData {
|
|||||||
this.resizer = new Resizer(this);
|
this.resizer = new Resizer(this);
|
||||||
this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevents ArDetector from starting
|
this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevents ArDetector from starting
|
||||||
|
|
||||||
this.logger.log('info', ['debug', 'init'], '[VideoData::ctor] Created videoData with vdid', this.vdid, '\nextension mode:', this.extensionMode)
|
this.logger.log('info', ['debug', 'init'], '[VideoData::ctor] Created videoData with vdid', this.vdid);
|
||||||
|
|
||||||
|
|
||||||
// Everything is set up at this point. However, we are still purely "read-only" at this point. Player CSS should not be changed until
|
// Everything is set up at this point. However, we are still purely "read-only" at this point. Player CSS should not be changed until
|
||||||
|
@ -69,12 +69,28 @@ class Resizer {
|
|||||||
pan: any = null;
|
pan: any = null;
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
cycleableAspectRatios: Ar[];
|
||||||
|
nextCycleOptionIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
//#region event bus configuration
|
//#region event bus configuration
|
||||||
private eventBusCommands = {
|
private eventBusCommands = {
|
||||||
'set-ar': [{
|
'set-ar': [{
|
||||||
function: (config: any) => {
|
function: (config: any) => {
|
||||||
this.manualZoom = false; // this only gets called from UI or keyboard shortcuts, making this action safe.
|
this.manualZoom = false; // this only gets called from UI or keyboard shortcuts, making this action safe.
|
||||||
|
|
||||||
|
if (config.type !== AspectRatioType.Cycle) {
|
||||||
this.setAr(config);
|
this.setAr(config);
|
||||||
|
} else {
|
||||||
|
// if we manually switched to a different aspect ratio, cycle from that ratio forward
|
||||||
|
const lastArIndex = this.cycleableAspectRatios.findIndex(x => x.type === this.lastAr.type && x.ratio === this.lastAr.ratio);
|
||||||
|
if (lastArIndex !== -1) {
|
||||||
|
this.nextCycleOptionIndex = (lastArIndex + 1) % this.cycleableAspectRatios.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setAr(this.cycleableAspectRatios[this.nextCycleOptionIndex]);
|
||||||
|
this.nextCycleOptionIndex = (this.nextCycleOptionIndex + 1) % this.cycleableAspectRatios.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
'set-alignment': [{
|
'set-alignment': [{
|
||||||
@ -124,6 +140,12 @@ class Resizer {
|
|||||||
// this.canPan = false;
|
// this.canPan = false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
this.cycleableAspectRatios =
|
||||||
|
(this.settings?.active?.commands?.crop ?? [])
|
||||||
|
.filter(x => [AspectRatioType.FitHeight, AspectRatioType.FitWidth, AspectRatioType.Fixed, AspectRatioType.Reset].includes(x?.arguments?.type))
|
||||||
|
.map(x => x.arguments) as Ar[];
|
||||||
|
|
||||||
|
this.nextCycleOptionIndex = 0;
|
||||||
this.userCssClassName = videoData.userCssClassName;
|
this.userCssClassName = videoData.userCssClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user