/* 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 }) { this.events = events; this.loading = loading; this.appRouter = appRouter; this.globalize = globalize; this.appHost = appHost; this.appSettings = appSettings; /** * @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'); window.api.taskbar.setProgress(time * 100 / this._duration); }; /** * @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; if (volume != this._volume) { this.setVolume(volume, false); } this.setPlaybackRate(1); this.setMute(false); if (this._currentPlayOptions.fullscreen) { this.appRouter.showVideoOsd().then(this.onNavigatedToOsd); } else { this.appRouter.setTransparency('backdrop'); this._videoDialog.dlg.style.zIndex = 'unset'; } // Need to override default style. this._videoDialog.style.setProperty('background', 'transparent', 'important'); window.api.taskbar.setControlsVisible(true); } if (this._paused) { this._paused = false; this.events.trigger(this, 'unpause'); window.api.taskbar.setPaused(false); } this.events.trigger(this, 'playing'); }; /** * @private */ this.onPause = () => { this._paused = true; // For Syncplay ready notification this.events.trigger(this, 'pause'); window.api.taskbar.setPaused(true); }; this.onWaiting = () => { this.events.trigger(this, 'waiting'); }; /** * @private * @param e {Event} The event received from the `