UNPKG

vidstack

Version:

Build awesome media experiences on the web.

73 lines (70 loc) 1.6 kB
import { setAttribute, isString } from 'maverick.js/std'; import { b as isMediaStream } from '../audio/loader.js'; import { H as HTMLMediaEvents } from './html–media-events.js'; import { N as NativeAudioTracks } from './native-audio-tracks.js'; class HTMLMediaProvider { constructor(_media) { this.j = _media; } setup(context) { new HTMLMediaEvents(this, context); if ("audioTracks" in this.media) new NativeAudioTracks(this, context); } get type() { return ""; } get media() { return this.j; } get paused() { return this.j.paused; } get muted() { return this.j.muted; } set muted(muted) { this.j.muted = muted; } get volume() { return this.j.volume; } set volume(volume) { this.j.volume = volume; } get currentTime() { return this.j.currentTime; } set currentTime(time) { this.j.currentTime = time; } get playsinline() { return this.j.hasAttribute("playsinline"); } set playsinline(playsinline) { setAttribute(this.j, "playsinline", playsinline); } get playbackRate() { return this.j.playbackRate; } set playbackRate(rate) { this.j.playbackRate = rate; } async play() { return this.j.play(); } async pause() { return this.j.pause(); } async loadSource({ src }, preload) { this.j.preload = preload; if (isMediaStream(src)) { this.j.srcObject = src; } else { this.j.srcObject = null; this.j.src = isString(src) ? src : window.URL.createObjectURL(src); } this.j.load(); } } export { HTMLMediaProvider as H };