mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2026-03-13 09:12:45 +08:00
Merge pull request #7645 from thornbill/playback-exit-crash
Fix crashes on playback exit
This commit is contained in:
@@ -12,7 +12,7 @@ import type { PlayerState } from 'types/playbackStopInfo';
|
||||
import type { Event } from 'utils/events';
|
||||
|
||||
/** The default image resolutions to provide to the media session.
|
||||
*
|
||||
*
|
||||
* Highest-to-lowest order matters; Firefox on Linux seems to use the first
|
||||
* image in the artwork array for its MPRIS interface. (#7630)
|
||||
*/
|
||||
@@ -96,8 +96,14 @@ class MediaSessionSubscriber extends PlaybackSubscriber {
|
||||
|
||||
private onMediaSessionUpdate(
|
||||
{ type: action }: Event,
|
||||
state: PlayerState = this.playbackManager.getPlayerState(this.player)
|
||||
stateOverride?: PlayerState
|
||||
) {
|
||||
if (!this.player) {
|
||||
console.debug('[MediaSessionSubscriber] no active player; resetting media session');
|
||||
return resetMediaSession();
|
||||
}
|
||||
|
||||
const state: PlayerState = stateOverride || this.playbackManager.getPlayerState(this.player);
|
||||
const item = state.NowPlayingItem;
|
||||
|
||||
if (!item) {
|
||||
|
||||
@@ -1365,6 +1365,9 @@ export class HtmlVideoPlayer {
|
||||
*/
|
||||
renderSubtitlesWithCustomElement(videoElement, track, item, targetTextTrackIndex) {
|
||||
this.fetchSubtitles(track, item).then((subtitleData) => {
|
||||
// Exit if the video element was destroyed while fetching subtitles
|
||||
if (!this.#mediaElement) return;
|
||||
|
||||
const subtitleAppearance = userSettings.getSubtitleAppearanceSettings();
|
||||
const subtitleVerticalPosition = parseInt(subtitleAppearance.verticalPosition, 10);
|
||||
|
||||
@@ -1478,7 +1481,10 @@ export class HtmlVideoPlayer {
|
||||
}
|
||||
|
||||
// download the track json
|
||||
this.fetchSubtitles(track, item).then(function (data) {
|
||||
this.fetchSubtitles(track, item).then(data => {
|
||||
// Exit if the video element was destroyed while fetching subtitles
|
||||
if (!this.#mediaElement) return;
|
||||
|
||||
console.debug(`downloaded ${data.TrackEvents.length} track events`);
|
||||
|
||||
const subtitleAppearance = userSettings.getSubtitleAppearanceSettings();
|
||||
|
||||
Reference in New Issue
Block a user