/* eslint-disable indent */ (function() { 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.setTransparency = dashboard.default.setBackdropTransparency.bind(dashboard); /** * @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.isLocalPlayer = 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; /** * @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.onPlaying = () => { if (!this._started) { this._started = true; this.loading.hide(); const volume = this.getSavedVolume() * 100; this.setVolume(volume, false); this.setPlaybackRate(this.getPlaybackRate()); // Hide backdrop when playback starts const dlg = this._videoDialog; if (dlg) { dlg.style.backgroundImage = ''; } // Navigate to OSD view to show playback screen if (this._currentPlayOptions.fullscreen) { this.appRouter.showVideoOsd(); // Lower video dialog z-index so OSD can receive input if (dlg) { dlg.style.zIndex = 'unset'; } } // Keep video fullscreen - native OSD is above it window.api.player.setVideoRectangle(0, 0, 0, 0); } 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 `