UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

57 lines (56 loc) 1.46 kB
/*! * NENT 2022 */ /* Exporting the class so that it can be used in other files. */ export class PlayerBase { constructor() { this.active = null; } /** * If the active audio is not null, pause it */ pause() { var _a; (_a = this.active) === null || _a === void 0 ? void 0 : _a.pause(); } /** * If the active audio is not null, then call the play() method on it */ play() { var _a; (_a = this.active) === null || _a === void 0 ? void 0 : _a.play(); } /** * If the active audio is not null, then call the stop() method on it */ stop() { var _a; (_a = this.active) === null || _a === void 0 ? void 0 : _a.stop(); } /** * If the active audio is not null, then call the resume() method on it */ resume() { var _a; (_a = this.active) === null || _a === void 0 ? void 0 : _a.resume(); } /** * It sets the mute state of the active player * @param {boolean} mute - boolean - Whether to mute or unmute the video */ mute(mute) { var _a; (_a = this.active) === null || _a === void 0 ? void 0 : _a.mute(mute); } /** * If the active strategy is being discarded, destroy it * @param {DiscardStrategy[]} reasons - DiscardStrategy[] */ discard(...reasons) { var _a; if (this.active && reasons.includes(this.active.discard)) { (_a = this.active) === null || _a === void 0 ? void 0 : _a.destroy(); this.active = null; } } }