/* eslint-disable indent */ function getMediaStreamAudioTracks(mediaSource) { return mediaSource.MediaStreams.filter(function (s) { return s.Type === 'Audio'; }); } class mpvVideoPlayer { constructor({ events, loading, appRouter, globalize, appHost, appSettings, confirm, dashboard }) { this.events = events; this.loading = loading; this.appRouter = appRouter; this.globalize = globalize; this.appHost = appHost; this.appSettings = appSettings; // this can be removed after 10.9 this.setTransparency = (dashboard && dashboard.setBackdropTransparency) ? dashboard.setBackdropTransparency.bind(dashboard) : appRouter.setTransparency.bind(appRouter); /** * @type {string} */ this.name = 'MPV Video Player'; /** * @type {string} */ this.type = 'mediaplayer'; /** * @type {string} */ this.id = 'mpvvideoplayer'; this.syncPlayWrapAs = 'htmlvideoplayer'; this.priority = -1; this.useFullSubtitleUrls = true; /** * @type {boolean} */ this.isFetching = false; /** * @type {HTMLDivElement | null | undefined} */ this._videoDialog = undefined; /** * @type {number | undefined} */ this._subtitleTrackIndexToSetOnPlaying = undefined; /** * @type {number | null} */ this._audioTrackIndexToSetOnPlaying = undefined; /** * @type {boolean | undefined} */ this._showTrackOffset = undefined; /** * @type {number | undefined} */ this._currentTrackOffset = undefined; /** * @type {string[] | undefined} */ this._supportedFeatures = undefined; /** * @type {string | undefined} */ this._currentSrc = undefined; /** * @type {boolean | undefined} */ this._started = undefined; /** * @type {boolean | undefined} */ this._timeUpdated = undefined; /** * @type {number | null | undefined} */ this._currentTime = undefined; /** * @private (used in other files) * @type {any | undefined} */ this._currentPlayOptions = undefined; /** * @type {any | undefined} */ this._lastProfile = undefined; /** * @type {number | undefined} */ this._duration = undefined; /** * @type {boolean} */ this._paused = false; /** * @type {int} */ this._volume = 100; /** * @type {boolean} */ this._muted = false; /** * @type {float} */ this._playRate = 1; /** * @type {boolean} */ this._hasConnection = false; /** * @private */ this.onEnded = () => { this.onEndedInternal(); }; /** * @private */ this.onTimeUpdate = (time) => { if (time && !this._timeUpdated) { this._timeUpdated = true; } this._currentTime = time; this.events.trigger(this, 'timeupdate'); }; /** * @private */ this.onNavigatedToOsd = () => { const dlg = this._videoDialog; if (dlg) { dlg.style.zIndex = 'unset'; } }; /** * @private */ this.onPlaying = () => { if (!this._started) { this._started = true; this.loading.hide(); const volume = this.getSavedVolume() * 100; this.setVolume(volume, false); this.setPlaybackRate(this.getPlaybackRate()); if (this._currentPlayOptions.fullscreen) { this.appRouter.showVideoOsd().then(this.onNavigatedToOsd); } else { this.setTransparency('backdrop'); this._videoDialog.dlg.style.zIndex = 'unset'; } // Need to override default style. this._videoDialog.style.setProperty('background', 'transparent', 'important'); } if (this._paused) { this._paused = false; this.events.trigger(this, 'unpause'); } this.events.trigger(this, 'playing'); }; /** * @private */ this.onPause = () => { this._paused = true; // For Syncplay ready notification this.events.trigger(this, 'pause'); }; this.onWaiting = () => { this.events.trigger(this, 'waiting'); }; /** * @private * @param e {Event} The event received from the `