tiny-essentials 1.28.4 → 1.28.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/changelog/1/28/5.md +31 -0
- package/changelog/1/28/6.md +11 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/index.cjs +4 -0
- package/dist/v1/basics/index.d.mts +3 -2
- package/dist/v1/basics/index.mjs +3 -2
- package/dist/v1/basics/mediaContent.cjs +1 -0
- package/dist/v1/basics/mediaContent.d.mts +4 -0
- package/dist/v1/basics/mediaContent.mjs +1 -0
- package/dist/v1/basics/objChecker.cjs +16 -0
- package/dist/v1/basics/objChecker.d.mts +12 -0
- package/dist/v1/basics/objChecker.mjs +14 -0
- package/dist/v1/basics/objFilter.cjs +0 -2
- package/dist/v1/basics/objFilter.d.mts +0 -2
- package/dist/v1/basics/objFilter.mjs +1 -2
- package/dist/v1/basics/promiseUtils.cjs +101 -0
- package/dist/v1/basics/promiseUtils.d.mts +31 -0
- package/dist/v1/basics/promiseUtils.mjs +89 -0
- package/dist/v1/css/TinyLoadingScreen.min.css +1 -1
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +3 -2
- package/dist/v1/index.mjs +3 -2
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +318 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +143 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +283 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +315 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +143 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +280 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +792 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +300 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +697 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +783 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +355 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +694 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.cjs +381 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.d.mts +704 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.mjs +343 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.cjs +546 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.d.mts +657 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.mjs +480 -0
- package/dist/v1/libs/TinyMediaPlayer/index.cjs +216 -0
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +162 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +190 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +627 -103
- package/dist/v1/libs/TinyMediaPlayer.d.mts +163 -65
- package/dist/v1/libs/TinyMediaPlayer.mjs +573 -93
- package/dist/v1/libs/TinyTimeout.cjs +4 -14
- package/dist/v1/libs/TinyTimeout.d.mts +1 -0
- package/dist/v1/libs/TinyTimeout.mjs +4 -13
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +13 -0
- package/docs/v1/basics/promiseUtils.md +32 -0
- package/docs/v1/libs/TinyMediaPlayer.md +268 -39
- package/docs/v1/libs/TinyTimeout.md +1 -14
- package/package.json +71 -10
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var objChecker = require('../../basics/objChecker.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
var index = require('./index.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
9
|
+
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
10
|
+
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
11
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const checkDestroy = utils.createCheckDestroyed('HtmlAudioAdapter');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Concrete implementation of the BaseMediaAdapter using HTML5 Audio.
|
|
19
|
+
* This class wraps the HTMLAudioElement and provides an adapter interface.
|
|
20
|
+
*/
|
|
21
|
+
class HtmlAudioAdapter extends index.BaseMediaAdapter {
|
|
22
|
+
/** @type {boolean} */
|
|
23
|
+
#destroyed = false;
|
|
24
|
+
|
|
25
|
+
get id() {
|
|
26
|
+
return 'html5Audio';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The internal HTMLAudioElement instance.
|
|
31
|
+
* @type {HTMLAudioElement}
|
|
32
|
+
*/
|
|
33
|
+
#audioElement = new Audio();
|
|
34
|
+
|
|
35
|
+
/** @type {string|null} */
|
|
36
|
+
#currentContentId = null;
|
|
37
|
+
|
|
38
|
+
get currentContentId() {
|
|
39
|
+
return this.#currentContentId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets whether the adapter has been destroyed.
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
get destroyed() {
|
|
47
|
+
return this.#destroyed;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Exposing the element to easily bind the 'ended' event in testing.
|
|
52
|
+
* @returns {HTMLAudioElement}
|
|
53
|
+
* @throws {Error} If the adapter has been destroyed.
|
|
54
|
+
*/
|
|
55
|
+
get audioElement() {
|
|
56
|
+
checkDestroy(this.#destroyed);
|
|
57
|
+
return this.#audioElement;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Initializes a new instance of the HtmlAudioAdapter.
|
|
62
|
+
*/
|
|
63
|
+
constructor() {
|
|
64
|
+
super();
|
|
65
|
+
|
|
66
|
+
this.#audioElement.addEventListener('play', () => this.emit('play'));
|
|
67
|
+
this.#audioElement.addEventListener('pause', () => this.emit('pause'));
|
|
68
|
+
this.#audioElement.addEventListener('ended', () => this.emit('ended'));
|
|
69
|
+
this.#audioElement.addEventListener('timeupdate', () => {
|
|
70
|
+
this.emit('timeupdate', this.getTimeData());
|
|
71
|
+
});
|
|
72
|
+
this.#audioElement.addEventListener('error', (error) => {
|
|
73
|
+
this.emit('error', error);
|
|
74
|
+
});
|
|
75
|
+
this.#audioElement.addEventListener('seeked', () => {
|
|
76
|
+
this.emit('seek', this.getCurrentTime());
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Synchronously checks whether the media adapter is fully initialized and ready.
|
|
82
|
+
* @returns {boolean} True if the adapter is ready, false otherwise.
|
|
83
|
+
*/
|
|
84
|
+
isReady() {
|
|
85
|
+
checkDestroy(this.#destroyed);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
91
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
92
|
+
*/
|
|
93
|
+
async waitIsReady() {
|
|
94
|
+
checkDestroy(this.#destroyed);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
100
|
+
* @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
|
|
101
|
+
*/
|
|
102
|
+
getTimeData() {
|
|
103
|
+
const total = this.getTotalDuration();
|
|
104
|
+
const current = this.getCurrentTime();
|
|
105
|
+
const remaining = total > 0 ? total - current : 0;
|
|
106
|
+
const playbackPercentage = total > 0 ? (current / total) * 100 : 0;
|
|
107
|
+
return { total, current, remaining, playbackPercentage };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Determines if the provided content is compatible with this adapter.
|
|
112
|
+
* @param {MediaContent} content - The media content object.
|
|
113
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
114
|
+
* @throws {TypeError} If content is not a valid object.
|
|
115
|
+
*/
|
|
116
|
+
static canHandle(content) {
|
|
117
|
+
if (!objChecker.isValidObj(content)) {
|
|
118
|
+
throw new TypeError('Content must be a valid object.');
|
|
119
|
+
}
|
|
120
|
+
return (
|
|
121
|
+
typeof content.url === 'string' &&
|
|
122
|
+
(content.url.startsWith('http') || content.url.startsWith('blob:')) &&
|
|
123
|
+
(content.mediaType === undefined || content.mediaType === 'audio')
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Determines if the provided content is compatible with this adapter.
|
|
129
|
+
* @param {MediaContent} content - The media content object.
|
|
130
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
131
|
+
* @throws {TypeError} If content is not a valid object.
|
|
132
|
+
*/
|
|
133
|
+
canHandle(content) {
|
|
134
|
+
checkDestroy(this.#destroyed);
|
|
135
|
+
return HtmlAudioAdapter.canHandle(content);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Plays the audio content provided via the URL.
|
|
140
|
+
* @param {MediaContent} content - The media content object containing the URL.
|
|
141
|
+
* @returns {Promise<void>} A promise that resolves when playback starts.
|
|
142
|
+
* @throws {TypeError} If the content URL is not a string.
|
|
143
|
+
*/
|
|
144
|
+
async play(content) {
|
|
145
|
+
checkDestroy(this.#destroyed);
|
|
146
|
+
if (!objChecker.isValidObj(content)) {
|
|
147
|
+
throw new TypeError('Content must be a valid object.');
|
|
148
|
+
}
|
|
149
|
+
if (typeof content?.url !== 'string') {
|
|
150
|
+
throw new TypeError('Valid media URL required.');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (this.#audioElement.src !== content.url) {
|
|
154
|
+
this.#currentContentId = content.url;
|
|
155
|
+
this.#audioElement.src = content.url;
|
|
156
|
+
this.#audioElement.load();
|
|
157
|
+
}
|
|
158
|
+
await this.#audioElement.play();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Pauses the audio playback.
|
|
163
|
+
* @returns {Promise<void>} A promise that resolves when playback is paused.
|
|
164
|
+
*/
|
|
165
|
+
async pause() {
|
|
166
|
+
checkDestroy(this.#destroyed);
|
|
167
|
+
this.#audioElement.pause();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Stops the audio playback and resets the current time to zero.
|
|
172
|
+
* @returns {Promise<void>} A promise that resolves when playback is stopped.
|
|
173
|
+
*/
|
|
174
|
+
async stop() {
|
|
175
|
+
checkDestroy(this.#destroyed);
|
|
176
|
+
this.#audioElement.pause();
|
|
177
|
+
this.#audioElement.currentTime = 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Seeks to a specific time in the audio.
|
|
182
|
+
* @param {number} timeMs - The target time in milliseconds.
|
|
183
|
+
* @returns {Promise<void>} A promise that resolves when the seek operation is complete.
|
|
184
|
+
* @throws {TypeError} If timeMs is not a number.
|
|
185
|
+
*/
|
|
186
|
+
async seek(timeMs) {
|
|
187
|
+
checkDestroy(this.#destroyed);
|
|
188
|
+
if (typeof timeMs !== 'number') {
|
|
189
|
+
throw new TypeError('Seek time must be a number.');
|
|
190
|
+
}
|
|
191
|
+
const currentTime = timeMs / 1000;
|
|
192
|
+
this.#audioElement.currentTime = currentTime;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Gets the current playback time.
|
|
197
|
+
* @returns {number} The current time in milliseconds.
|
|
198
|
+
*/
|
|
199
|
+
getCurrentTime() {
|
|
200
|
+
checkDestroy(this.#destroyed);
|
|
201
|
+
return Math.floor(this.#audioElement.currentTime * 1000);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Gets the total duration of the audio.
|
|
206
|
+
* @returns {number} The total duration in milliseconds.
|
|
207
|
+
*/
|
|
208
|
+
getTotalDuration() {
|
|
209
|
+
checkDestroy(this.#destroyed);
|
|
210
|
+
const duration = this.#audioElement.duration;
|
|
211
|
+
return Number.isFinite(duration) ? Math.floor(duration * 1000) : 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Gets the remaining time until the audio ends.
|
|
216
|
+
* @returns {number} The remaining time in milliseconds.
|
|
217
|
+
*/
|
|
218
|
+
getRemainingTime() {
|
|
219
|
+
checkDestroy(this.#destroyed);
|
|
220
|
+
const total = this.getTotalDuration();
|
|
221
|
+
const current = this.getCurrentTime();
|
|
222
|
+
return total > 0 ? total - current : 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Gets the percentage of the audio that has been played.
|
|
227
|
+
* @returns {number} The percentage from 0 to 100.
|
|
228
|
+
*/
|
|
229
|
+
getPlaybackPercentage() {
|
|
230
|
+
checkDestroy(this.#destroyed);
|
|
231
|
+
const total = this.getTotalDuration();
|
|
232
|
+
const current = this.getCurrentTime();
|
|
233
|
+
return total > 0 ? (current / total) * 100 : 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Sets the volume level of the audio.
|
|
238
|
+
* @param {number} volume - The volume level from 0.0 to 1.0.
|
|
239
|
+
* @throws {RangeError} If the volume is not between 0.0 and 1.0.
|
|
240
|
+
*/
|
|
241
|
+
setVolume(volume) {
|
|
242
|
+
this.volume = volume;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Gets the volume level of the audio.
|
|
247
|
+
* @returns {number} The volume level from 0.0 to 1.0.
|
|
248
|
+
*/
|
|
249
|
+
getVolume() {
|
|
250
|
+
return this.volume;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Gets the current volume level of the audio.
|
|
255
|
+
* @returns {number} The current volume level from 0.0 to 1.0.
|
|
256
|
+
*/
|
|
257
|
+
get volume() {
|
|
258
|
+
checkDestroy(this.#destroyed);
|
|
259
|
+
return this.#audioElement.volume;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Sets the volume level.
|
|
264
|
+
* @param {number} value - The volume level from 0.0 to 1.0.
|
|
265
|
+
* @throws {RangeError} If the volume is not between 0.0 and 1.0.
|
|
266
|
+
*/
|
|
267
|
+
set volume(value) {
|
|
268
|
+
checkDestroy(this.#destroyed);
|
|
269
|
+
if (typeof value !== 'number' || value < 0 || value > 1) {
|
|
270
|
+
throw new RangeError('Volume must be a number between 0.0 and 1.0.');
|
|
271
|
+
}
|
|
272
|
+
this.#audioElement.volume = value;
|
|
273
|
+
this.emit('volumeChange', value);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
278
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
279
|
+
* @returns {Promise<ContentData>}
|
|
280
|
+
*/
|
|
281
|
+
async getContentData() {
|
|
282
|
+
return {
|
|
283
|
+
id: '',
|
|
284
|
+
createdAt: '',
|
|
285
|
+
artistId: '',
|
|
286
|
+
artistName: '',
|
|
287
|
+
description: '',
|
|
288
|
+
title: '',
|
|
289
|
+
duration: 0,
|
|
290
|
+
avatar: '',
|
|
291
|
+
url: '',
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Cleans up the adapter resources and marks it as destroyed.
|
|
297
|
+
* @returns {Promise<void>}
|
|
298
|
+
*/
|
|
299
|
+
async destroy() {
|
|
300
|
+
if (this.#destroyed) return;
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
this.#audioElement.pause();
|
|
304
|
+
this.#audioElement.src = '';
|
|
305
|
+
this.#currentContentId = null;
|
|
306
|
+
this.#audioElement.load();
|
|
307
|
+
} catch (error) {
|
|
308
|
+
// We catch errors during cleanup to ensure the destruction process completes.
|
|
309
|
+
} finally {
|
|
310
|
+
// @ts-ignore
|
|
311
|
+
this.#audioElement = null;
|
|
312
|
+
}
|
|
313
|
+
this.#destroyed = true;
|
|
314
|
+
super.destroy();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
exports.HtmlAudioAdapter = HtmlAudioAdapter;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
3
|
+
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
4
|
+
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
5
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
6
|
+
*/
|
|
7
|
+
export type PictureDataType = import('../../basics/mediaContent.mjs').PictureDataType;
|
|
8
|
+
export type MediaContent = import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>;
|
|
9
|
+
export type ContentTimeData = import('./index.mjs').ContentTimeData;
|
|
10
|
+
export type ContentData = import('./index.mjs').ContentData;
|
|
11
|
+
import { BaseMediaAdapter } from './index.mjs';
|
|
12
|
+
/**
|
|
13
|
+
* Concrete implementation of the BaseMediaAdapter using HTML5 Audio.
|
|
14
|
+
* This class wraps the HTMLAudioElement and provides an adapter interface.
|
|
15
|
+
*/
|
|
16
|
+
declare class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
17
|
+
#private;
|
|
18
|
+
get id(): string;
|
|
19
|
+
get currentContentId(): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Gets whether the adapter has been destroyed.
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
get destroyed(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Exposing the element to easily bind the 'ended' event in testing.
|
|
27
|
+
* @returns {HTMLAudioElement}
|
|
28
|
+
* @throws {Error} If the adapter has been destroyed.
|
|
29
|
+
*/
|
|
30
|
+
get audioElement(): HTMLAudioElement;
|
|
31
|
+
/**
|
|
32
|
+
* Initializes a new instance of the HtmlAudioAdapter.
|
|
33
|
+
*/
|
|
34
|
+
constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Synchronously checks whether the media adapter is fully initialized and ready.
|
|
37
|
+
* @returns {boolean} True if the adapter is ready, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
isReady(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
42
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
43
|
+
*/
|
|
44
|
+
waitIsReady(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
47
|
+
* @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
|
|
48
|
+
*/
|
|
49
|
+
getTimeData(): ContentTimeData;
|
|
50
|
+
/**
|
|
51
|
+
* Determines if the provided content is compatible with this adapter.
|
|
52
|
+
* @param {MediaContent} content - The media content object.
|
|
53
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
54
|
+
* @throws {TypeError} If content is not a valid object.
|
|
55
|
+
*/
|
|
56
|
+
static canHandle(content: MediaContent): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Determines if the provided content is compatible with this adapter.
|
|
59
|
+
* @param {MediaContent} content - The media content object.
|
|
60
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
61
|
+
* @throws {TypeError} If content is not a valid object.
|
|
62
|
+
*/
|
|
63
|
+
canHandle(content: MediaContent): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Plays the audio content provided via the URL.
|
|
66
|
+
* @param {MediaContent} content - The media content object containing the URL.
|
|
67
|
+
* @returns {Promise<void>} A promise that resolves when playback starts.
|
|
68
|
+
* @throws {TypeError} If the content URL is not a string.
|
|
69
|
+
*/
|
|
70
|
+
play(content: MediaContent): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Pauses the audio playback.
|
|
73
|
+
* @returns {Promise<void>} A promise that resolves when playback is paused.
|
|
74
|
+
*/
|
|
75
|
+
pause(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Stops the audio playback and resets the current time to zero.
|
|
78
|
+
* @returns {Promise<void>} A promise that resolves when playback is stopped.
|
|
79
|
+
*/
|
|
80
|
+
stop(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Seeks to a specific time in the audio.
|
|
83
|
+
* @param {number} timeMs - The target time in milliseconds.
|
|
84
|
+
* @returns {Promise<void>} A promise that resolves when the seek operation is complete.
|
|
85
|
+
* @throws {TypeError} If timeMs is not a number.
|
|
86
|
+
*/
|
|
87
|
+
seek(timeMs: number): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the current playback time.
|
|
90
|
+
* @returns {number} The current time in milliseconds.
|
|
91
|
+
*/
|
|
92
|
+
getCurrentTime(): number;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the total duration of the audio.
|
|
95
|
+
* @returns {number} The total duration in milliseconds.
|
|
96
|
+
*/
|
|
97
|
+
getTotalDuration(): number;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the remaining time until the audio ends.
|
|
100
|
+
* @returns {number} The remaining time in milliseconds.
|
|
101
|
+
*/
|
|
102
|
+
getRemainingTime(): number;
|
|
103
|
+
/**
|
|
104
|
+
* Gets the percentage of the audio that has been played.
|
|
105
|
+
* @returns {number} The percentage from 0 to 100.
|
|
106
|
+
*/
|
|
107
|
+
getPlaybackPercentage(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the volume level of the audio.
|
|
110
|
+
* @param {number} volume - The volume level from 0.0 to 1.0.
|
|
111
|
+
* @throws {RangeError} If the volume is not between 0.0 and 1.0.
|
|
112
|
+
*/
|
|
113
|
+
setVolume(volume: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* Gets the volume level of the audio.
|
|
116
|
+
* @returns {number} The volume level from 0.0 to 1.0.
|
|
117
|
+
*/
|
|
118
|
+
getVolume(): number;
|
|
119
|
+
/**
|
|
120
|
+
* Gets the current volume level of the audio.
|
|
121
|
+
* @returns {number} The current volume level from 0.0 to 1.0.
|
|
122
|
+
*/
|
|
123
|
+
get volume(): number;
|
|
124
|
+
/**
|
|
125
|
+
* Sets the volume level.
|
|
126
|
+
* @param {number} value - The volume level from 0.0 to 1.0.
|
|
127
|
+
* @throws {RangeError} If the volume is not between 0.0 and 1.0.
|
|
128
|
+
*/
|
|
129
|
+
set volume(value: number);
|
|
130
|
+
/**
|
|
131
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
132
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
133
|
+
* @returns {Promise<ContentData>}
|
|
134
|
+
*/
|
|
135
|
+
getContentData(): Promise<ContentData>;
|
|
136
|
+
/**
|
|
137
|
+
* Cleans up the adapter resources and marks it as destroyed.
|
|
138
|
+
* @returns {Promise<void>}
|
|
139
|
+
*/
|
|
140
|
+
destroy(): Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
export { HtmlAudioAdapter };
|
|
143
|
+
//# sourceMappingURL=HtmlAudio.d.mts.map
|