diff --git a/packages/vidstack/src/core/state/media-request-manager.ts b/packages/vidstack/src/core/state/media-request-manager.ts index f902bc714..884231943 100644 --- a/packages/vidstack/src/core/state/media-request-manager.ts +++ b/packages/vidstack/src/core/state/media-request-manager.ts @@ -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(); } diff --git a/packages/vidstack/src/utils/dom.ts b/packages/vidstack/src/utils/dom.ts index b58c2b496..c1f9f7678 100644 --- a/packages/vidstack/src/utils/dom.ts +++ b/packages/vidstack/src/utils/dom.ts @@ -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) {