This commit is contained in:
Harvey authored and Harvey Zack committed 2022-02-11 11:20:54 +08:00
1 parent b80a30bcc0
commit 5e9057f060
12 files changed
+98 -285

No files matched your search

+1 -1
View File
@@ -33,12 +33,12 @@ export default class Icons {
setting,
fullscreen,
fullscreenWeb,
pip,
arrowLeft,
arrowRight,
playbackRate,
aspectRatio,
config,
pip,
...art.option.icons,
};
@@ -4,16 +4,20 @@ export default function subtitleOffsetMix(art) {
const { clamp } = art.constructor.utils;
const { notice, template, i18n } = art;
let offsetCache = 0;
let cuesCache = [];
art.on('subtitle:switch', () => {
cuesCache = [];
});
def(art, 'subtitleOffset', {
get() {
return offsetCache;
},
set(value) {
if (template.$track && template.$track.track) {
const cues = Array.from(template.$track.track.cues);
const time = clamp(value, -5, 5);
offsetCache = clamp(value, -5, 5);
for (let index = 0; index < cues.length; index++) {
const cue = cues[index];
@@ -23,8 +27,8 @@ export default function subtitleOffsetMix(art) {
endTime: cue.endTime,
};
}
cue.startTime = clamp(cuesCache[index].startTime + time, 0, art.duration);
cue.endTime = clamp(cuesCache[index].endTime + time, 0, art.duration);
cue.startTime = clamp(cuesCache[index].startTime + offsetCache, 0, art.duration);
cue.endTime = clamp(cuesCache[index].endTime + offsetCache, 0, art.duration);
}
art.subtitle.update();
+2 -2
View File
@@ -1,9 +1,9 @@
import Component from '../utils/component';
import { append, addClass, setStyle, inverseClass, includeFromEvent } from '../utils';
import flip from './flip';
import aspectRatio from './aspectRatio';
import playbackRate from './playbackRate';
import subtitleOffset from './subtitleOffset';
import Component from '../utils/component';
import { append, addClass, setStyle, inverseClass, includeFromEvent } from '../utils';
function makeRecursion(option) {
for (let index = 0; index < option.length; index++) {