Skip to content

Commit

Permalink
Fix OSD event after player reset
Browse files Browse the repository at this point in the history
  • Loading branch information
viown committed Oct 15, 2024
1 parent b627667 commit add4f20
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/components/playback/skipsegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { EventType } from 'types/eventType';
import './skipbutton.scss';
import dom from 'scripts/dom';
import globalize from 'lib/globalize';
import { PlayTarget } from 'types/playTarget';
import { Plugin } from 'types/plugin';

interface ShowOptions {
animate?: boolean;
Expand All @@ -23,21 +25,6 @@ class SkipSegment extends PlaybackSubscriber {
super(playbackManager);

this.onOsdChanged = this.onOsdChanged.bind(this);

Events.on(document, EventType.SHOW_VIDEO_OSD, this.onOsdChanged);
}

onOsdChanged(_e: Event, isOpen: boolean) {
if (this.currentSegment) {
if (isOpen) {
this.showSkipButton({
animate: false,
keep: true
});
} else if (!this.hideTimeout) {
this.hideSkipButton();
}
}
}

onHideComplete() {
Expand Down Expand Up @@ -129,6 +116,19 @@ class SkipSegment extends PlaybackSubscriber {
}
}

onOsdChanged(_e: Event, isOpen: boolean) {
if (this.currentSegment) {
if (isOpen) {
this.showSkipButton({
animate: false,
keep: true
});
} else if (!this.hideTimeout) {
this.hideSkipButton();
}
}
}

onPromptSkip(segment: MediaSegmentDto) {
if (!this.currentSegment) {
this.currentSegment = segment;
Expand All @@ -152,6 +152,13 @@ class SkipSegment extends PlaybackSubscriber {
}
}

onPlayerChange(): void {
if (this.playbackManager.getCurrentPlayer()) {
Events.off(document, EventType.SHOW_VIDEO_OSD, this.onOsdChanged);
Events.on(document, EventType.SHOW_VIDEO_OSD, this.onOsdChanged);
}
}

onPlaybackStop() {
this.currentSegment = null;
this.hideSkipButton();
Expand Down

0 comments on commit add4f20

Please sign in to comment.