UNPKG

vidstack

Version:

Build awesome media experiences on the web.

74 lines (71 loc) 1.72 kB
import { listenEvent, DOMEvent } from 'maverick.js/std'; import { $ as canUseVideoPresentation } from '../../../media-core.js'; class VideoPresentation { constructor(_video, _media) { this.qa = _video; this.j = _media; listenEvent(this.qa, "webkitpresentationmodechanged", this.Kh.bind(this)); } Ga = "inline"; get Jh() { return canUseVideoPresentation(this.qa); } async Ih(mode) { if (this.Ga === mode) return; this.qa.webkitSetPresentationMode(mode); } Kh() { const prevMode = this.Ga; this.Ga = this.qa.webkitPresentationMode; this.j.player?.dispatchEvent( new DOMEvent("video-presentation-change", { detail: this.Ga, trigger: event }) ); ["fullscreen", "picture-in-picture"].forEach((type) => { if (this.Ga === type || prevMode === type) { this.j.delegate.p(`${type}-change`, { detail: this.Ga === type, trigger: event }); } }); } } class FullscreenPresentationAdapter { constructor(_presentation) { this.Hh = _presentation; } get active() { return this.Hh.Ga === "fullscreen"; } get supported() { return this.Hh.Jh; } async enter() { this.Hh.Ih("fullscreen"); } async exit() { this.Hh.Ih("inline"); } } class PIPPresentationAdapter { constructor(_presentation) { this.Hh = _presentation; } get active() { return this.Hh.Ga === "picture-in-picture"; } get supported() { return this.Hh.Jh; } async enter() { this.Hh.Ih("picture-in-picture"); } async exit() { this.Hh.Ih("inline"); } } export { FullscreenPresentationAdapter as F, PIPPresentationAdapter as P, VideoPresentation as V };