tiny-essentials 1.28.5 → 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/6.md +11 -0
- package/dist/v1/TinyAdvancedRaffle.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/TinyUploadClicker.min.js +1 -1
- package/dist/v1/css/TinyLoadingScreen.min.css +1 -1
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +53 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +25 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +49 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +53 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +25 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +49 -3
- 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 +124 -12
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +96 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +107 -10
- 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/index.cjs +52 -1
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +60 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +47 -1
- package/dist/v1/libs/TinyMediaPlayer.cjs +38 -0
- package/dist/v1/libs/TinyMediaPlayer.d.mts +13 -0
- package/dist/v1/libs/TinyMediaPlayer.mjs +38 -0
- package/docs/v1/libs/TinyMediaPlayer.md +31 -9
- package/package.json +51 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:absolute;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-container{height:100%;width:100%;display:flex;align-items:center}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif;margin:auto}.loading-overlay .loading-spinner{position:relative;border:4px solid
|
|
1
|
+
.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:absolute;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-container{height:100%;width:100%;display:flex;align-items:center}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif;margin:auto}.loading-overlay .loading-spinner{position:relative;border:4px solid rgba(255,255,255,.3);border-top:4px solid #fff;border-radius:50%;width:50px;height:50px;margin:0 auto 15px;animation:loading-spin 1s linear infinite}.loading-overlay .loading-spinner::after{content:"";position:absolute;top:50%;left:50%;width:20px;height:20px;transform:translate(-50%, -50%);border-radius:50%;background:rgba(0,0,0,0);pointer-events:none}.loading-overlay .loading-message{font-size:1.2em;user-select:none !important}@keyframes loading-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
|
|
@@ -8,6 +8,7 @@ var index = require('./index.cjs');
|
|
|
8
8
|
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
9
9
|
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
10
10
|
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
11
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
|
|
@@ -71,6 +72,27 @@ class HtmlAudioAdapter extends index.BaseMediaAdapter {
|
|
|
71
72
|
this.#audioElement.addEventListener('error', (error) => {
|
|
72
73
|
this.emit('error', error);
|
|
73
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;
|
|
74
96
|
}
|
|
75
97
|
|
|
76
98
|
/**
|
|
@@ -91,8 +113,7 @@ class HtmlAudioAdapter extends index.BaseMediaAdapter {
|
|
|
91
113
|
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
92
114
|
* @throws {TypeError} If content is not a valid object.
|
|
93
115
|
*/
|
|
94
|
-
canHandle(content) {
|
|
95
|
-
checkDestroy(this.#destroyed);
|
|
116
|
+
static canHandle(content) {
|
|
96
117
|
if (!objChecker.isValidObj(content)) {
|
|
97
118
|
throw new TypeError('Content must be a valid object.');
|
|
98
119
|
}
|
|
@@ -103,6 +124,17 @@ class HtmlAudioAdapter extends index.BaseMediaAdapter {
|
|
|
103
124
|
);
|
|
104
125
|
}
|
|
105
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
|
+
|
|
106
138
|
/**
|
|
107
139
|
* Plays the audio content provided via the URL.
|
|
108
140
|
* @param {MediaContent} content - The media content object containing the URL.
|
|
@@ -158,7 +190,6 @@ class HtmlAudioAdapter extends index.BaseMediaAdapter {
|
|
|
158
190
|
}
|
|
159
191
|
const currentTime = timeMs / 1000;
|
|
160
192
|
this.#audioElement.currentTime = currentTime;
|
|
161
|
-
this.emit('seek', currentTime);
|
|
162
193
|
}
|
|
163
194
|
|
|
164
195
|
/**
|
|
@@ -242,6 +273,25 @@ class HtmlAudioAdapter extends index.BaseMediaAdapter {
|
|
|
242
273
|
this.emit('volumeChange', value);
|
|
243
274
|
}
|
|
244
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
|
+
|
|
245
295
|
/**
|
|
246
296
|
* Cleans up the adapter resources and marks it as destroyed.
|
|
247
297
|
* @returns {Promise<void>}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
3
3
|
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
4
4
|
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
5
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
5
6
|
*/
|
|
6
7
|
export type PictureDataType = import('../../basics/mediaContent.mjs').PictureDataType;
|
|
7
8
|
export type MediaContent = import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>;
|
|
8
9
|
export type ContentTimeData = import('./index.mjs').ContentTimeData;
|
|
10
|
+
export type ContentData = import('./index.mjs').ContentData;
|
|
9
11
|
import { BaseMediaAdapter } from './index.mjs';
|
|
10
12
|
/**
|
|
11
13
|
* Concrete implementation of the BaseMediaAdapter using HTML5 Audio.
|
|
@@ -30,11 +32,28 @@ declare class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
30
32
|
* Initializes a new instance of the HtmlAudioAdapter.
|
|
31
33
|
*/
|
|
32
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>;
|
|
33
45
|
/**
|
|
34
46
|
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
35
47
|
* @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
|
|
36
48
|
*/
|
|
37
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;
|
|
38
57
|
/**
|
|
39
58
|
* Determines if the provided content is compatible with this adapter.
|
|
40
59
|
* @param {MediaContent} content - The media content object.
|
|
@@ -108,6 +127,12 @@ declare class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
108
127
|
* @throws {RangeError} If the volume is not between 0.0 and 1.0.
|
|
109
128
|
*/
|
|
110
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>;
|
|
111
136
|
/**
|
|
112
137
|
* Cleans up the adapter resources and marks it as destroyed.
|
|
113
138
|
* @returns {Promise<void>}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
3
3
|
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
4
4
|
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
5
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
5
6
|
*/
|
|
6
7
|
import { isValidObj } from '../../basics/objChecker.mjs';
|
|
7
8
|
import { createCheckDestroyed } from '../utils.mjs';
|
|
@@ -57,6 +58,25 @@ class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
57
58
|
this.#audioElement.addEventListener('error', (error) => {
|
|
58
59
|
this.emit('error', error);
|
|
59
60
|
});
|
|
61
|
+
this.#audioElement.addEventListener('seeked', () => {
|
|
62
|
+
this.emit('seek', this.getCurrentTime());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Synchronously checks whether the media adapter is fully initialized and ready.
|
|
67
|
+
* @returns {boolean} True if the adapter is ready, false otherwise.
|
|
68
|
+
*/
|
|
69
|
+
isReady() {
|
|
70
|
+
checkDestroy(this.#destroyed);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
75
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
76
|
+
*/
|
|
77
|
+
async waitIsReady() {
|
|
78
|
+
checkDestroy(this.#destroyed);
|
|
79
|
+
return;
|
|
60
80
|
}
|
|
61
81
|
/**
|
|
62
82
|
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
@@ -75,8 +95,7 @@ class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
75
95
|
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
76
96
|
* @throws {TypeError} If content is not a valid object.
|
|
77
97
|
*/
|
|
78
|
-
canHandle(content) {
|
|
79
|
-
checkDestroy(this.#destroyed);
|
|
98
|
+
static canHandle(content) {
|
|
80
99
|
if (!isValidObj(content)) {
|
|
81
100
|
throw new TypeError('Content must be a valid object.');
|
|
82
101
|
}
|
|
@@ -84,6 +103,16 @@ class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
84
103
|
(content.url.startsWith('http') || content.url.startsWith('blob:')) &&
|
|
85
104
|
(content.mediaType === undefined || content.mediaType === 'audio'));
|
|
86
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Determines if the provided content is compatible with this adapter.
|
|
108
|
+
* @param {MediaContent} content - The media content object.
|
|
109
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
110
|
+
* @throws {TypeError} If content is not a valid object.
|
|
111
|
+
*/
|
|
112
|
+
canHandle(content) {
|
|
113
|
+
checkDestroy(this.#destroyed);
|
|
114
|
+
return HtmlAudioAdapter.canHandle(content);
|
|
115
|
+
}
|
|
87
116
|
/**
|
|
88
117
|
* Plays the audio content provided via the URL.
|
|
89
118
|
* @param {MediaContent} content - The media content object containing the URL.
|
|
@@ -135,7 +164,6 @@ class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
135
164
|
}
|
|
136
165
|
const currentTime = timeMs / 1000;
|
|
137
166
|
this.#audioElement.currentTime = currentTime;
|
|
138
|
-
this.emit('seek', currentTime);
|
|
139
167
|
}
|
|
140
168
|
/**
|
|
141
169
|
* Gets the current playback time.
|
|
@@ -210,6 +238,24 @@ class HtmlAudioAdapter extends BaseMediaAdapter {
|
|
|
210
238
|
this.#audioElement.volume = value;
|
|
211
239
|
this.emit('volumeChange', value);
|
|
212
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
243
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
244
|
+
* @returns {Promise<ContentData>}
|
|
245
|
+
*/
|
|
246
|
+
async getContentData() {
|
|
247
|
+
return {
|
|
248
|
+
id: '',
|
|
249
|
+
createdAt: '',
|
|
250
|
+
artistId: '',
|
|
251
|
+
artistName: '',
|
|
252
|
+
description: '',
|
|
253
|
+
title: '',
|
|
254
|
+
duration: 0,
|
|
255
|
+
avatar: '',
|
|
256
|
+
url: '',
|
|
257
|
+
};
|
|
258
|
+
}
|
|
213
259
|
/**
|
|
214
260
|
* Cleans up the adapter resources and marks it as destroyed.
|
|
215
261
|
* @returns {Promise<void>}
|
|
@@ -8,6 +8,7 @@ var index = require('./index.cjs');
|
|
|
8
8
|
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
9
9
|
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
10
10
|
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
11
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
|
|
@@ -68,6 +69,27 @@ class HtmlVideoAdapter extends index.BaseMediaAdapter {
|
|
|
68
69
|
this.#videoElement.addEventListener('error', (error) => {
|
|
69
70
|
this.emit('error', error);
|
|
70
71
|
});
|
|
72
|
+
this.#videoElement.addEventListener('seeked', () => {
|
|
73
|
+
this.emit('seek', this.getCurrentTime());
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Synchronously checks whether the media adapter is fully initialized and ready.
|
|
79
|
+
* @returns {boolean} True if the adapter is ready, false otherwise.
|
|
80
|
+
*/
|
|
81
|
+
isReady() {
|
|
82
|
+
checkDestroy(this.#destroyed);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
88
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
89
|
+
*/
|
|
90
|
+
async waitIsReady() {
|
|
91
|
+
checkDestroy(this.#destroyed);
|
|
92
|
+
return;
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
/**
|
|
@@ -88,8 +110,7 @@ class HtmlVideoAdapter extends index.BaseMediaAdapter {
|
|
|
88
110
|
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
89
111
|
* @throws {TypeError} If content is not a valid object.
|
|
90
112
|
*/
|
|
91
|
-
canHandle(content) {
|
|
92
|
-
checkDestroy(this.#destroyed);
|
|
113
|
+
static canHandle(content) {
|
|
93
114
|
if (!objChecker.isValidObj(content)) {
|
|
94
115
|
throw new TypeError('Content must be a valid object.');
|
|
95
116
|
}
|
|
@@ -100,6 +121,17 @@ class HtmlVideoAdapter extends index.BaseMediaAdapter {
|
|
|
100
121
|
);
|
|
101
122
|
}
|
|
102
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Determines if the provided content is compatible with this adapter.
|
|
126
|
+
* @param {MediaContent} content - The media content object.
|
|
127
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
128
|
+
* @throws {TypeError} If content is not a valid object.
|
|
129
|
+
*/
|
|
130
|
+
canHandle(content) {
|
|
131
|
+
checkDestroy(this.#destroyed);
|
|
132
|
+
return HtmlVideoAdapter.canHandle(content);
|
|
133
|
+
}
|
|
134
|
+
|
|
103
135
|
/**
|
|
104
136
|
* Plays the video content provided via the URL.
|
|
105
137
|
* @param {MediaContent} content - The media content object containing the URL.
|
|
@@ -155,7 +187,6 @@ class HtmlVideoAdapter extends index.BaseMediaAdapter {
|
|
|
155
187
|
}
|
|
156
188
|
const currentTime = timeMs / 1000;
|
|
157
189
|
this.#videoElement.currentTime = currentTime;
|
|
158
|
-
this.emit('seek', currentTime);
|
|
159
190
|
}
|
|
160
191
|
|
|
161
192
|
/**
|
|
@@ -239,6 +270,25 @@ class HtmlVideoAdapter extends index.BaseMediaAdapter {
|
|
|
239
270
|
this.emit('volumeChange', value);
|
|
240
271
|
}
|
|
241
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
275
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
276
|
+
* @returns {Promise<ContentData>}
|
|
277
|
+
*/
|
|
278
|
+
async getContentData() {
|
|
279
|
+
return {
|
|
280
|
+
id: '',
|
|
281
|
+
createdAt: '',
|
|
282
|
+
artistId: '',
|
|
283
|
+
artistName: '',
|
|
284
|
+
description: '',
|
|
285
|
+
title: '',
|
|
286
|
+
duration: 0,
|
|
287
|
+
avatar: '',
|
|
288
|
+
url: '',
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
242
292
|
/**
|
|
243
293
|
* Cleans up the adapter resources and marks it as destroyed.
|
|
244
294
|
* @returns {Promise<void>}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
3
3
|
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
4
4
|
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
5
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
5
6
|
*/
|
|
6
7
|
export type PictureDataType = import('../../basics/mediaContent.mjs').PictureDataType;
|
|
7
8
|
export type MediaContent = import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>;
|
|
8
9
|
export type ContentTimeData = import('./index.mjs').ContentTimeData;
|
|
10
|
+
export type ContentData = import('./index.mjs').ContentData;
|
|
9
11
|
import { BaseMediaAdapter } from './index.mjs';
|
|
10
12
|
/**
|
|
11
13
|
* Concrete implementation of the BaseMediaAdapter using HTML5 Video.
|
|
@@ -30,11 +32,28 @@ declare class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
30
32
|
* Initializes a new instance of the HtmlVideoAdapter.
|
|
31
33
|
*/
|
|
32
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>;
|
|
33
45
|
/**
|
|
34
46
|
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
35
47
|
* @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
|
|
36
48
|
*/
|
|
37
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;
|
|
38
57
|
/**
|
|
39
58
|
* Determines if the provided content is compatible with this adapter.
|
|
40
59
|
* @param {MediaContent} content - The media content object.
|
|
@@ -108,6 +127,12 @@ declare class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
108
127
|
* @throws {RangeError} If the volume is not between 0.0 and 1.0.
|
|
109
128
|
*/
|
|
110
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>;
|
|
111
136
|
/**
|
|
112
137
|
* Cleans up the adapter resources and marks it as destroyed.
|
|
113
138
|
* @returns {Promise<void>}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
3
3
|
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
4
4
|
* @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
|
|
5
|
+
* @typedef {import('./index.mjs').ContentData} ContentData
|
|
5
6
|
*/
|
|
6
7
|
import { isValidObj } from '../../basics/objChecker.mjs';
|
|
7
8
|
import { createCheckDestroyed } from '../utils.mjs';
|
|
@@ -54,6 +55,25 @@ class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
54
55
|
this.#videoElement.addEventListener('error', (error) => {
|
|
55
56
|
this.emit('error', error);
|
|
56
57
|
});
|
|
58
|
+
this.#videoElement.addEventListener('seeked', () => {
|
|
59
|
+
this.emit('seek', this.getCurrentTime());
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Synchronously checks whether the media adapter is fully initialized and ready.
|
|
64
|
+
* @returns {boolean} True if the adapter is ready, false otherwise.
|
|
65
|
+
*/
|
|
66
|
+
isReady() {
|
|
67
|
+
checkDestroy(this.#destroyed);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
72
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
73
|
+
*/
|
|
74
|
+
async waitIsReady() {
|
|
75
|
+
checkDestroy(this.#destroyed);
|
|
76
|
+
return;
|
|
57
77
|
}
|
|
58
78
|
/**
|
|
59
79
|
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
@@ -72,8 +92,7 @@ class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
72
92
|
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
73
93
|
* @throws {TypeError} If content is not a valid object.
|
|
74
94
|
*/
|
|
75
|
-
canHandle(content) {
|
|
76
|
-
checkDestroy(this.#destroyed);
|
|
95
|
+
static canHandle(content) {
|
|
77
96
|
if (!isValidObj(content)) {
|
|
78
97
|
throw new TypeError('Content must be a valid object.');
|
|
79
98
|
}
|
|
@@ -81,6 +100,16 @@ class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
81
100
|
(content.url.startsWith('http') || content.url.startsWith('blob:')) &&
|
|
82
101
|
(content.mediaType === undefined || content.mediaType === 'video'));
|
|
83
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Determines if the provided content is compatible with this adapter.
|
|
105
|
+
* @param {MediaContent} content - The media content object.
|
|
106
|
+
* @returns {boolean} True if the content is compatible, false otherwise.
|
|
107
|
+
* @throws {TypeError} If content is not a valid object.
|
|
108
|
+
*/
|
|
109
|
+
canHandle(content) {
|
|
110
|
+
checkDestroy(this.#destroyed);
|
|
111
|
+
return HtmlVideoAdapter.canHandle(content);
|
|
112
|
+
}
|
|
84
113
|
/**
|
|
85
114
|
* Plays the video content provided via the URL.
|
|
86
115
|
* @param {MediaContent} content - The media content object containing the URL.
|
|
@@ -132,7 +161,6 @@ class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
132
161
|
}
|
|
133
162
|
const currentTime = timeMs / 1000;
|
|
134
163
|
this.#videoElement.currentTime = currentTime;
|
|
135
|
-
this.emit('seek', currentTime);
|
|
136
164
|
}
|
|
137
165
|
/**
|
|
138
166
|
* Gets the current playback time.
|
|
@@ -207,6 +235,24 @@ class HtmlVideoAdapter extends BaseMediaAdapter {
|
|
|
207
235
|
this.#videoElement.volume = value;
|
|
208
236
|
this.emit('volumeChange', value);
|
|
209
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
240
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
241
|
+
* @returns {Promise<ContentData>}
|
|
242
|
+
*/
|
|
243
|
+
async getContentData() {
|
|
244
|
+
return {
|
|
245
|
+
id: '',
|
|
246
|
+
createdAt: '',
|
|
247
|
+
artistId: '',
|
|
248
|
+
artistName: '',
|
|
249
|
+
description: '',
|
|
250
|
+
title: '',
|
|
251
|
+
duration: 0,
|
|
252
|
+
avatar: '',
|
|
253
|
+
url: '',
|
|
254
|
+
};
|
|
255
|
+
}
|
|
210
256
|
/**
|
|
211
257
|
* Cleans up the adapter resources and marks it as destroyed.
|
|
212
258
|
* @returns {Promise<void>}
|