Skip to content

Commit

Permalink
fix(player): exit fs and pip on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Apr 19, 2024
1 parent b263650 commit 068f1fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/vidstack/src/core/state/media-request-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ export class MediaRequestManager extends MediaPlayerController implements MediaR
}

protected override onDestroy(): void {
try {
const destroyEvent = this.createEvent('destroy'),
{ pictureInPicture, fullscreen } = this.$state;

if (fullscreen()) this._exitFullscreen('prefer-media', destroyEvent);

if (pictureInPicture()) this._exitPictureInPicture(destroyEvent);
} catch (e) {
// no-op
}

this._providerQueue._reset();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vidstack/src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const intervalJobs = new Set<() => void>();
if (!__SERVER__) {
window.setInterval(() => {
for (const job of intervalJobs) job();
}, 1000);
}, 500);
}

export function scheduleIntervalJob(job: () => void) {
Expand Down

0 comments on commit 068f1fa

Please sign in to comment.