Merge remote-tracking branch 'upstream/master' into fonts

This commit is contained in:
nyanmisaka 2020-08-19 17:25:25 +08:00
commit f1804009e6
326 changed files with 21514 additions and 23576 deletions

View file

@ -105,7 +105,7 @@ function tryRemoveElement(elem) {
}
function hidePrePlaybackPage() {
let animatedPage = document.querySelector('.page:not(.hide)');
const animatedPage = document.querySelector('.page:not(.hide)');
animatedPage.classList.add('hide');
// At this point, we must hide the scrollbar placeholder, so it's not being displayed while the item is being loaded
document.body.classList.remove('force-scroll');
@ -150,7 +150,7 @@ function tryRemoveElement(elem) {
/**
* @type {string}
*/
name
name;
/**
* @type {string}
*/
@ -730,7 +730,7 @@ function tryRemoveElement(elem) {
const elem = e.target;
this.destroyCustomTrack(elem);
onEndedInternal(this, elem, this.onError);
}
};
/**
* @private
@ -760,7 +760,7 @@ function tryRemoveElement(elem) {
}
events.trigger(this, 'timeupdate');
}
};
/**
* @private
@ -773,7 +773,7 @@ function tryRemoveElement(elem) {
const elem = e.target;
saveVolume(elem.volume);
events.trigger(this, 'volumechange');
}
};
/**
* @private
@ -785,7 +785,7 @@ function tryRemoveElement(elem) {
this.onStartedAndNavigatedToOsd();
}
}
};
/**
* @private
@ -832,14 +832,14 @@ function tryRemoveElement(elem) {
}
}
events.trigger(this, 'playing');
}
};
/**
* @private
*/
onPlay = () => {
events.trigger(this, 'unpause');
}
};
/**
* @private
@ -865,21 +865,21 @@ function tryRemoveElement(elem) {
*/
onClick = () => {
events.trigger(this, 'click');
}
};
/**
* @private
*/
onDblClick = () => {
events.trigger(this, 'dblclick');
}
};
/**
* @private
*/
onPause = () => {
events.trigger(this, 'pause');
}
};
onWaiting() {
events.trigger(this, 'waiting');
@ -929,7 +929,7 @@ function tryRemoveElement(elem) {
}
onErrorInternal(this, type);
}
};
/**
* @private
@ -1152,7 +1152,7 @@ function tryRemoveElement(elem) {
*/
getCueCss(appearance, selector) {
return `${selector}::cue {
${appearance.text.map((s) => `${s.name}:${s.value}!important;`).join('')}
${appearance.text.map((s) => s.value !== undefined && s.value !== '' ? `${s.name}:${s.value}!important;` : '').join('')}
}`;
}
@ -1170,7 +1170,7 @@ function tryRemoveElement(elem) {
document.getElementsByTagName('head')[0].appendChild(styleElem);
}
styleElem.innerHTML = this.getCueCss(subtitleAppearanceHelper.getStyles(userSettings.getSubtitleAppearanceSettings(), true), '.htmlvideoplayer');
styleElem.innerHTML = this.getCueCss(subtitleAppearanceHelper.getStyles(userSettings.getSubtitleAppearanceSettings()), '.htmlvideoplayer');
});
}
@ -1215,17 +1215,28 @@ function tryRemoveElement(elem) {
// download the track json
this.fetchSubtitles(track, item).then(function (data) {
// show in ui
console.debug(`downloaded ${data.TrackEvents.length} track events`);
// add some cues to show the text
// in safari, the cues need to be added before setting the track mode to showing
for (const trackEvent of data.TrackEvents) {
const trackCueObject = window.VTTCue || window.TextTrackCue;
const cue = new trackCueObject(trackEvent.StartPositionTicks / 10000000, trackEvent.EndPositionTicks / 10000000, normalizeTrackEventText(trackEvent.Text, false));
import('userSettings').then((userSettings) => {
// show in ui
console.debug(`downloaded ${data.TrackEvents.length} track events`);
trackElement.addCue(cue);
}
trackElement.mode = 'showing';
const subtitleAppearance = userSettings.getSubtitleAppearanceSettings();
const cueLine = parseInt(subtitleAppearance.verticalPosition, 10);
// add some cues to show the text
// in safari, the cues need to be added before setting the track mode to showing
for (const trackEvent of data.TrackEvents) {
const trackCueObject = window.VTTCue || window.TextTrackCue;
const cue = new trackCueObject(trackEvent.StartPositionTicks / 10000000, trackEvent.EndPositionTicks / 10000000, normalizeTrackEventText(trackEvent.Text, false));
if (cue.line === 'auto') {
cue.line = cueLine;
}
trackElement.addCue(cue);
}
trackElement.mode = 'showing';
});
});
}
@ -1308,7 +1319,7 @@ function tryRemoveElement(elem) {
}
let html = '';
let cssClass = 'htmlvideoplayer';
const cssClass = 'htmlvideoplayer';
// Can't autoplay in these browsers so we need to use the full controls, at least until playback starts
if (!appHost.supports('htmlvideoautoplay')) {
@ -1643,6 +1654,31 @@ function tryRemoveElement(elem) {
return null;
}
getSupportedPlaybackRates() {
return [{
name: '0.5x',
id: 0.5
}, {
name: '0.75x',
id: 0.75
}, {
name: '1x',
id: 1.0
}, {
name: '1.25x',
id: 1.25
}, {
name: '1.5x',
id: 1.5
}, {
name: '1.75x',
id: 1.75
}, {
name: '2x',
id: 2.0
}];
}
setVolume(val) {
const mediaElement = this.#mediaElement;
if (mediaElement) {
@ -1683,7 +1719,7 @@ function tryRemoveElement(elem) {
setAspectRatio(val) {
const mediaElement = this.#mediaElement;
if (mediaElement) {
if ('auto' === val) {
if (val === 'auto') {
mediaElement.style.removeProperty('object-fit');
} else {
mediaElement.style['object-fit'] = val;