UNPKG

@ktt45678/vidstack

Version:

UI component library for building high-quality, accessible video and audio experiences on the web.

58 lines (55 loc) 1.57 kB
import { signal, effect, listenEvent } from './vidstack-C6myozhB.js'; import './vidstack-CTW_LGt6.js'; class HTMLRemotePlaybackAdapter { constructor(_media, _ctx) { this.a = _media; this.b = _ctx; this.pb = signal(false); this.he(); } get supported() { return this.pb(); } he() { if (!this.a?.remote || !this.kg) return; this.a.remote.watchAvailability((available) => { this.pb.set(available); }).catch(() => { this.pb.set(false); }); effect(this.Fi.bind(this)); } Fi() { if (!this.pb()) return; const events = ["connecting", "connect", "disconnect"], onStateChange = this.ie.bind(this); onStateChange(); listenEvent(this.a, "playing", onStateChange); for (const type of events) { listenEvent(this.a.remote, type, onStateChange); } } async prompt() { if (!this.supported) throw Error("Not supported on this platform."); if (this.la === "airplay" && this.a.webkitShowPlaybackTargetPicker) { return this.a.webkitShowPlaybackTargetPicker(); } return this.a.remote.prompt(); } ie(event) { const state = this.a.remote.state; if (state === this.za) return; const detail = { type: this.la, state }; this.b.delegate.c("remote-playback-change", detail, event); this.za = state; } } class HTMLAirPlayAdapter extends HTMLRemotePlaybackAdapter { constructor() { super(...arguments); this.la = "airplay"; } get kg() { return "WebKitPlaybackTargetAvailabilityEvent" in window; } } export { HTMLAirPlayAdapter };