tiny-essentials 1.28.5 → 1.28.7
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 +14 -0
- package/changelog/1/28/7.md +7 -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 +80 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +40 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +73 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +80 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +40 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +73 -3
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +846 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +315 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +745 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +151 -12
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +111 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +131 -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 +79 -1
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +75 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +71 -1
- package/dist/v1/libs/TinyMediaPlayer.cjs +75 -0
- package/dist/v1/libs/TinyMediaPlayer.d.mts +22 -0
- package/dist/v1/libs/TinyMediaPlayer.mjs +71 -0
- package/docs/v1/libs/TinyMediaPlayer.md +56 -40
- package/package.json +55 -10
|
@@ -18,6 +18,7 @@ const checkDestroy = utils.createCheckDestroyed('TinyMediaPlayer');
|
|
|
18
18
|
* @typedef {import('../basics/mediaContent.mjs').MediaLoadingErrorData} MediaLoadingErrorData
|
|
19
19
|
* @typedef {import('../basics/mediaContent.mjs').UnknownArtistGetter} UnknownArtistGetter
|
|
20
20
|
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentTimeData} ContentTimeData
|
|
21
|
+
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentData} ContentData
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -126,6 +127,9 @@ class TinyMediaPlayer extends events.EventEmitter {
|
|
|
126
127
|
/** @type {boolean} */
|
|
127
128
|
#isPlaying = false;
|
|
128
129
|
|
|
130
|
+
/** @type {boolean} */
|
|
131
|
+
#isMuted = false;
|
|
132
|
+
|
|
129
133
|
/** @type {number} */
|
|
130
134
|
#volume = 1.0;
|
|
131
135
|
|
|
@@ -682,6 +686,39 @@ class TinyMediaPlayer extends events.EventEmitter {
|
|
|
682
686
|
}
|
|
683
687
|
}
|
|
684
688
|
|
|
689
|
+
/** @returns {boolean} True if the player is currently muted. */
|
|
690
|
+
get isMuted() {
|
|
691
|
+
checkDestroy(this.#destroyed);
|
|
692
|
+
return this.#isMuted;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Sets the mute state of the player.
|
|
697
|
+
* This state is synchronized with the active adapter and respected when playing new tracks.
|
|
698
|
+
* @param {boolean} value - True to mute, false to unMute.
|
|
699
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
700
|
+
*/
|
|
701
|
+
set isMuted(value) {
|
|
702
|
+
checkDestroy(this.#destroyed);
|
|
703
|
+
if (typeof value !== 'boolean') {
|
|
704
|
+
throw new TypeError('isMuted must be a boolean.');
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
this.#isMuted = value;
|
|
708
|
+
|
|
709
|
+
// Synchronize with the active adapter immediately
|
|
710
|
+
try {
|
|
711
|
+
const adapter = this.#getActiveAdapter();
|
|
712
|
+
if (adapter) {
|
|
713
|
+
value ? adapter.mute() : adapter.unMute();
|
|
714
|
+
}
|
|
715
|
+
} catch (error) {
|
|
716
|
+
// If no active adapter, we just wait for the next play() call to apply the state
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
this.emit('muteChange', this.#isMuted);
|
|
720
|
+
}
|
|
721
|
+
|
|
685
722
|
// ==========================================
|
|
686
723
|
// ADAPTER MANAGEMENT
|
|
687
724
|
// ==========================================
|
|
@@ -1124,6 +1161,7 @@ class TinyMediaPlayer extends events.EventEmitter {
|
|
|
1124
1161
|
}
|
|
1125
1162
|
|
|
1126
1163
|
await adapter.play(this.#playlist[this.#currentIndex]);
|
|
1164
|
+
if (this.#isMuted) await adapter.mute();
|
|
1127
1165
|
this.#isPlaying = true;
|
|
1128
1166
|
this.emit('play', this.#currentIndex);
|
|
1129
1167
|
}
|
|
@@ -1358,6 +1396,43 @@ class TinyMediaPlayer extends events.EventEmitter {
|
|
|
1358
1396
|
}
|
|
1359
1397
|
}
|
|
1360
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
1401
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
1402
|
+
* @returns {Promise<ContentData>}
|
|
1403
|
+
*/
|
|
1404
|
+
async getContentData() {
|
|
1405
|
+
checkDestroy(this.#destroyed);
|
|
1406
|
+
const defaultData = {
|
|
1407
|
+
id: '',
|
|
1408
|
+
createdAt: '',
|
|
1409
|
+
artistId: '',
|
|
1410
|
+
artistName: '',
|
|
1411
|
+
description: '',
|
|
1412
|
+
title: '',
|
|
1413
|
+
duration: 0,
|
|
1414
|
+
avatar: '',
|
|
1415
|
+
url: '',
|
|
1416
|
+
};
|
|
1417
|
+
try {
|
|
1418
|
+
const adapter = this.#getActiveAdapter();
|
|
1419
|
+
return adapter ? adapter.getContentData() : defaultData;
|
|
1420
|
+
} catch {
|
|
1421
|
+
return defaultData;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
1427
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
1428
|
+
*/
|
|
1429
|
+
async waitIsReady() {
|
|
1430
|
+
checkDestroy(this.#destroyed);
|
|
1431
|
+
const adapter = this.#getActiveAdapter();
|
|
1432
|
+
if (!adapter) return;
|
|
1433
|
+
return adapter.waitIsReady();
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1361
1436
|
// ==========================================
|
|
1362
1437
|
// DESTROYER
|
|
1363
1438
|
// ==========================================
|
|
@@ -9,6 +9,7 @@ export type LoadingMediaProgress = import('../basics/mediaContent.mjs').LoadingM
|
|
|
9
9
|
export type MediaLoadingErrorData = import('../basics/mediaContent.mjs').MediaLoadingErrorData;
|
|
10
10
|
export type UnknownArtistGetter = import('../basics/mediaContent.mjs').UnknownArtistGetter;
|
|
11
11
|
export type ContentTimeData = import('./TinyMediaPlayer/index.mjs').ContentTimeData;
|
|
12
|
+
export type ContentData = import('./TinyMediaPlayer/index.mjs').ContentData;
|
|
12
13
|
export type LoopModeType = 'NONE' | 'TRACK' | 'PLAYLIST';
|
|
13
14
|
export type TinyMediaPlayerOptions = {
|
|
14
15
|
/**
|
|
@@ -52,6 +53,7 @@ export type SearchResult = {
|
|
|
52
53
|
* @typedef {import('../basics/mediaContent.mjs').MediaLoadingErrorData} MediaLoadingErrorData
|
|
53
54
|
* @typedef {import('../basics/mediaContent.mjs').UnknownArtistGetter} UnknownArtistGetter
|
|
54
55
|
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentTimeData} ContentTimeData
|
|
56
|
+
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentData} ContentData
|
|
55
57
|
*/
|
|
56
58
|
/**
|
|
57
59
|
* The loop configuration modes.
|
|
@@ -218,6 +220,15 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
218
220
|
* @throws {TypeError} If the value is not a string or is empty.
|
|
219
221
|
*/
|
|
220
222
|
set volumeStorageKey(value: string);
|
|
223
|
+
/** @returns {boolean} True if the player is currently muted. */
|
|
224
|
+
get isMuted(): boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Sets the mute state of the player.
|
|
227
|
+
* This state is synchronized with the active adapter and respected when playing new tracks.
|
|
228
|
+
* @param {boolean} value - True to mute, false to unMute.
|
|
229
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
230
|
+
*/
|
|
231
|
+
set isMuted(value: boolean);
|
|
221
232
|
get adapters(): BaseMediaAdapter[];
|
|
222
233
|
get adaptersSize(): number;
|
|
223
234
|
static get defaultAdapterEventNames(): string[];
|
|
@@ -380,6 +391,17 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
380
391
|
* @returns {number} A value between 0 and 100.
|
|
381
392
|
*/
|
|
382
393
|
getPlaybackPercentage(): number;
|
|
394
|
+
/**
|
|
395
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
396
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
397
|
+
* @returns {Promise<ContentData>}
|
|
398
|
+
*/
|
|
399
|
+
getContentData(): Promise<ContentData>;
|
|
400
|
+
/**
|
|
401
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
402
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
403
|
+
*/
|
|
404
|
+
waitIsReady(): Promise<void>;
|
|
383
405
|
/**
|
|
384
406
|
* Safely destroys the TinyMediaPlayer instance.
|
|
385
407
|
* This method stops active playback, clears the internal playlist,
|
|
@@ -14,6 +14,7 @@ const checkDestroy = createCheckDestroyed('TinyMediaPlayer');
|
|
|
14
14
|
* @typedef {import('../basics/mediaContent.mjs').MediaLoadingErrorData} MediaLoadingErrorData
|
|
15
15
|
* @typedef {import('../basics/mediaContent.mjs').UnknownArtistGetter} UnknownArtistGetter
|
|
16
16
|
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentTimeData} ContentTimeData
|
|
17
|
+
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentData} ContentData
|
|
17
18
|
*/
|
|
18
19
|
/**
|
|
19
20
|
* The loop configuration modes.
|
|
@@ -97,6 +98,8 @@ class TinyMediaPlayer extends EventEmitter {
|
|
|
97
98
|
#isRandom = false;
|
|
98
99
|
/** @type {boolean} */
|
|
99
100
|
#isPlaying = false;
|
|
101
|
+
/** @type {boolean} */
|
|
102
|
+
#isMuted = false;
|
|
100
103
|
/** @type {number} */
|
|
101
104
|
#volume = 1.0;
|
|
102
105
|
/** @type {boolean} */
|
|
@@ -607,6 +610,35 @@ class TinyMediaPlayer extends EventEmitter {
|
|
|
607
610
|
console.warn('[TinyMediaPlayer] Failed to migrate volume storage key.', error);
|
|
608
611
|
}
|
|
609
612
|
}
|
|
613
|
+
/** @returns {boolean} True if the player is currently muted. */
|
|
614
|
+
get isMuted() {
|
|
615
|
+
checkDestroy(this.#destroyed);
|
|
616
|
+
return this.#isMuted;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Sets the mute state of the player.
|
|
620
|
+
* This state is synchronized with the active adapter and respected when playing new tracks.
|
|
621
|
+
* @param {boolean} value - True to mute, false to unMute.
|
|
622
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
623
|
+
*/
|
|
624
|
+
set isMuted(value) {
|
|
625
|
+
checkDestroy(this.#destroyed);
|
|
626
|
+
if (typeof value !== 'boolean') {
|
|
627
|
+
throw new TypeError('isMuted must be a boolean.');
|
|
628
|
+
}
|
|
629
|
+
this.#isMuted = value;
|
|
630
|
+
// Synchronize with the active adapter immediately
|
|
631
|
+
try {
|
|
632
|
+
const adapter = this.#getActiveAdapter();
|
|
633
|
+
if (adapter) {
|
|
634
|
+
value ? adapter.mute() : adapter.unMute();
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
// If no active adapter, we just wait for the next play() call to apply the state
|
|
639
|
+
}
|
|
640
|
+
this.emit('muteChange', this.#isMuted);
|
|
641
|
+
}
|
|
610
642
|
// ==========================================
|
|
611
643
|
// ADAPTER MANAGEMENT
|
|
612
644
|
// ==========================================
|
|
@@ -1006,6 +1038,8 @@ class TinyMediaPlayer extends EventEmitter {
|
|
|
1006
1038
|
adapter.setVolume(this.#volume);
|
|
1007
1039
|
}
|
|
1008
1040
|
await adapter.play(this.#playlist[this.#currentIndex]);
|
|
1041
|
+
if (this.#isMuted)
|
|
1042
|
+
await adapter.mute();
|
|
1009
1043
|
this.#isPlaying = true;
|
|
1010
1044
|
this.emit('play', this.#currentIndex);
|
|
1011
1045
|
}
|
|
@@ -1223,6 +1257,43 @@ class TinyMediaPlayer extends EventEmitter {
|
|
|
1223
1257
|
return 0;
|
|
1224
1258
|
}
|
|
1225
1259
|
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
1262
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
1263
|
+
* @returns {Promise<ContentData>}
|
|
1264
|
+
*/
|
|
1265
|
+
async getContentData() {
|
|
1266
|
+
checkDestroy(this.#destroyed);
|
|
1267
|
+
const defaultData = {
|
|
1268
|
+
id: '',
|
|
1269
|
+
createdAt: '',
|
|
1270
|
+
artistId: '',
|
|
1271
|
+
artistName: '',
|
|
1272
|
+
description: '',
|
|
1273
|
+
title: '',
|
|
1274
|
+
duration: 0,
|
|
1275
|
+
avatar: '',
|
|
1276
|
+
url: '',
|
|
1277
|
+
};
|
|
1278
|
+
try {
|
|
1279
|
+
const adapter = this.#getActiveAdapter();
|
|
1280
|
+
return adapter ? adapter.getContentData() : defaultData;
|
|
1281
|
+
}
|
|
1282
|
+
catch {
|
|
1283
|
+
return defaultData;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
1288
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
1289
|
+
*/
|
|
1290
|
+
async waitIsReady() {
|
|
1291
|
+
checkDestroy(this.#destroyed);
|
|
1292
|
+
const adapter = this.#getActiveAdapter();
|
|
1293
|
+
if (!adapter)
|
|
1294
|
+
return;
|
|
1295
|
+
return adapter.waitIsReady();
|
|
1296
|
+
}
|
|
1226
1297
|
// ==========================================
|
|
1227
1298
|
// DESTROYER
|
|
1228
1299
|
// ==========================================
|
|
@@ -9,17 +9,35 @@
|
|
|
9
9
|
To support different media platforms, `TinyMediaPlayer` relies on **Adapters**. You must create a class that extends `BaseMediaAdapter` for every new service you wish to support.
|
|
10
10
|
|
|
11
11
|
### 🛠️ `BaseMediaAdapter` (Abstract Class)
|
|
12
|
-
*This class cannot be instantiated directly. It serves as an interface.*
|
|
12
|
+
*This class cannot be instantiated directly. It serves as an interface that all specific API wrappers must extend and implement.*
|
|
13
13
|
|
|
14
|
+
#### Properties
|
|
15
|
+
| Property | Type | Description |
|
|
16
|
+
| :--- | :--- | :--- |
|
|
17
|
+
| `destroyed` | `boolean` | Indicates if the adapter instance has been destroyed. |
|
|
18
|
+
|
|
19
|
+
#### Methods
|
|
14
20
|
| Method | Description | Parameters | Returns |
|
|
15
21
|
| :--- | :--- | :--- | :--- |
|
|
16
|
-
| `canHandle` |
|
|
17
|
-
| `
|
|
22
|
+
| `canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
|
|
23
|
+
| `isReady` | Synchronously checks if the adapter is ready. | None | `boolean` |
|
|
24
|
+
| `waitIsReady` | Asynchronously waits until the adapter is ready. | None | `Promise<void>` |
|
|
25
|
+
| `play` | Starts or resumes playback of the provided content. | `content: MediaContent` | `Promise<void>` |
|
|
18
26
|
| `pause` | Pauses the current playback. | None | `Promise<void>` |
|
|
19
|
-
| `stop` | Stops playback and resets the platform state. | None | `Promise<void>` |
|
|
20
|
-
| `seek` |
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
27
|
+
| `stop` | Stops the playback completely and resets the platform state. | None | `Promise<void>` |
|
|
28
|
+
| `seek` | Seeks to a specific time in the media timeline. | `timeMs: number` | `Promise<void>` |
|
|
29
|
+
| `isMuted` | Checks whether the player is currently muted. | None | `boolean \| null` |
|
|
30
|
+
| `mute` | Mutes the current playback. | None | `Promise<void>` |
|
|
31
|
+
| `unMute` | Unmutes the current playback. | None | `Promise<void>` |
|
|
32
|
+
| `getCurrentTime` | Retrieves the current playback position. | None | `number` (ms) |
|
|
33
|
+
| `getTotalDuration` | Gets the total duration of the content. | None | `number` (ms) |
|
|
34
|
+
| `getRemainingTime` | Gets the remaining time until the content ends. | None | `number` (ms) |
|
|
35
|
+
| `getPlaybackPercentage` | Gets the percentage of the content that has been played. | None | `number` (0 to 100) |
|
|
36
|
+
| `getTimeData` | Retrieves a consolidated object containing all time-related metrics. | None | `ContentTimeData` |
|
|
37
|
+
| `setVolume` | Sets the playback volume for the underlying API. | `volume: number` (0.0 to 1.0) | `void` |
|
|
38
|
+
| `getVolume` | Gets the current playback volume. | None | `number` (0.0 to 1.0) |
|
|
39
|
+
| `getContentData` | Retrieves the metadata of the loaded content. | None | `Promise<ContentData>` |
|
|
40
|
+
| `destroy` | Cleans up the instance and marks it as destroyed. | None | `void` |
|
|
23
41
|
|
|
24
42
|
---
|
|
25
43
|
|
|
@@ -31,7 +49,8 @@ You can integrate `TinyMediaPlayer` into your project using two methods: using t
|
|
|
31
49
|
The library provides several optimized adapters for common media sources. You can import them and register them directly with your player instance.
|
|
32
50
|
|
|
33
51
|
**Available Adapters:**
|
|
34
|
-
* `YoutubeMediaAdapter` from `tiny-essentials/libs/TinyMediaPlayer/Youtube`
|
|
52
|
+
* `YoutubeMediaAdapter` from `tiny-essentials/libs/TinyMediaPlayer/Youtube` (https://www.youtube.com/watch?v=XXXXXXXXXXX)
|
|
53
|
+
* `SoundCloudMediaAdapter` from `tiny-essentials/libs/TinyMediaPlayer/SoundCloud` (https://api.soundcloud.com/tracks/XXXXXXXXX (From SoundCloud Embed))
|
|
35
54
|
* `HtmlAudioAdapter` from `tiny-essentials/libs/TinyMediaPlayer/HtmlAudio`
|
|
36
55
|
* `HtmlVideoAdapter` from `tiny-essentials/libs/TinyMediaPlayer/HtmlVideo`
|
|
37
56
|
|
|
@@ -46,9 +65,9 @@ const player = new TinyMediaPlayer({
|
|
|
46
65
|
});
|
|
47
66
|
|
|
48
67
|
YoutubeMediaAdapter.defaultContainer = YoutubeMediaAdapter.createIframeContainer({
|
|
49
|
-
videoId: 'fzKvGbQ9SgY',
|
|
50
|
-
hidden: true,
|
|
51
|
-
autoplay: false,
|
|
68
|
+
videoId: 'fzKvGbQ9SgY',
|
|
69
|
+
hidden: true,
|
|
70
|
+
autoplay: false,
|
|
52
71
|
});
|
|
53
72
|
|
|
54
73
|
// Register the ready-made adapters
|
|
@@ -76,41 +95,34 @@ class MyCustomServiceAdapter extends BaseMediaAdapter {
|
|
|
76
95
|
* @param {MediaContent} content - The media content to check.
|
|
77
96
|
* @returns {boolean} - True if the URL matches the service.
|
|
78
97
|
*/
|
|
79
|
-
canHandle(content) {
|
|
98
|
+
static canHandle(content) {
|
|
80
99
|
return content.url.startsWith('https://example.com/');
|
|
81
100
|
}
|
|
82
101
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* @param {MediaContent} content - The content to play.
|
|
86
|
-
* @returns {Promise<void>}
|
|
87
|
-
*/
|
|
88
|
-
async play(content) {
|
|
89
|
-
console.log(`Starting playback for: ${content.title}`);
|
|
90
|
-
// Logic to interface with the custom service API goes here
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async pause() {
|
|
94
|
-
// Logic to pause custom service playback
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async stop() {
|
|
98
|
-
// Logic to stop custom service playback
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async seek(timeMs) {
|
|
102
|
-
// Logic to seek in custom service playback
|
|
102
|
+
canHandle(content) {
|
|
103
|
+
return MyCustomServiceAdapter.canHandle(content);
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return 0;
|
|
106
|
+
async play(content) {
|
|
107
|
+
console.log(`Starting playback for: ${content.title}`);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
110
|
+
async pause() {}
|
|
111
|
+
async stop() {}
|
|
112
|
+
async seek(timeMs) {}
|
|
113
|
+
getCurrentTime() { return 0; }
|
|
114
|
+
setVolume(volume) {}
|
|
115
|
+
getVolume() { return 1.0; }
|
|
116
|
+
async getContentData() { return {}; }
|
|
117
|
+
async waitIsReady() {}
|
|
118
|
+
isReady() { return true; }
|
|
119
|
+
isMuted() { return false; }
|
|
120
|
+
async mute() {}
|
|
121
|
+
async unMute() {}
|
|
122
|
+
getTotalDuration() { return 0; }
|
|
123
|
+
getRemainingTime() { return 0; }
|
|
124
|
+
getPlaybackPercentage() { return 0; }
|
|
125
|
+
getTimeData() { return {}; }
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
// Registering the custom adapter
|
|
@@ -192,6 +204,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
192
204
|
| `isRandom` | `boolean` | Enables or disables shuffle mode. |
|
|
193
205
|
| `isPlaying` | `boolean` | Indicates if media is currently playing. |
|
|
194
206
|
| `volume` | `number` | The current volume level (strictly between `0.0` and `1.0`). |
|
|
207
|
+
| `isMuted` | `boolean` | Sets the mute state of the player. |
|
|
195
208
|
|
|
196
209
|
#### 🎨 UX & Customization
|
|
197
210
|
| Property | Type | Description |
|
|
@@ -252,13 +265,15 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
252
265
|
* **`next()`**: **(Async)** Advances to the next track (respects `loopMode` and `isRandom`).
|
|
253
266
|
* **`prev()`**: **(Async)** Returns to the previous track (respects `loopMode` and `isRandom`).
|
|
254
267
|
* **`seek(timeMs)`**: **(Async)** Jumps to a specific millisecond in the current track.
|
|
255
|
-
* **`step(stepMs)`**: **(Async)** Moves the timeline forward (
|
|
268
|
+
* **`step(stepMs)`**: **(Async)** Moves the timeline forward (+) or backward (-) by `stepMs`.
|
|
256
269
|
|
|
257
270
|
#### ⏳ Time Utilities
|
|
258
271
|
* **`getCurrentTime()`**: Gets the current playback time in milliseconds.
|
|
259
272
|
* **`getTotalDuration()`**: Gets the total duration of the current track in milliseconds.
|
|
260
273
|
* **`getRemainingTime()`**: Gets the remaining time until the current track ends in milliseconds.
|
|
261
274
|
* **`getPlaybackPercentage()`**: Gets the percentage of the current track that has been played (0-100).
|
|
275
|
+
* **`getContentData()`**: Retrieves structured metadata for the current content.
|
|
276
|
+
* **`waitIsReady()`**: **(Async)** Waits until the active adapter is fully initialized.
|
|
262
277
|
|
|
263
278
|
#### ♻️ Lifecycle
|
|
264
279
|
* **`destroy()`**: **(Async)** Safely stops playback, clears state, removes adapters, and detaches all listeners to prevent memory leaks.
|
|
@@ -291,6 +306,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
291
306
|
| `smoothStopVolumeChange` | `boolean` | Emitted when the smooth stop volume setting is toggled. |
|
|
292
307
|
| `fadeVolumeSpeedChange` | `number` | Emitted when the volume fade speed is updated. |
|
|
293
308
|
| `prevClickTimeoutDurationChange` | `number` | Emitted when the "repeat on prev" timeout duration is updated. |
|
|
309
|
+
| `muteChange` | `boolean` | Emitted when the mute state is toggled. |
|
|
294
310
|
|
|
295
311
|
### 💀 Lifecycle Events
|
|
296
312
|
| Event | Data Type | Description |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.7",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tiny-essentials-fork": "./TinyFork.mjs"
|
|
@@ -108,6 +108,10 @@
|
|
|
108
108
|
"require": "./dist/v1/basics/text.cjs",
|
|
109
109
|
"import": "./dist/v1/basics/text.mjs"
|
|
110
110
|
},
|
|
111
|
+
"./basics/promiseUtils": {
|
|
112
|
+
"require": "./dist/v1/basics/promiseUtils.cjs",
|
|
113
|
+
"import": "./dist/v1/basics/promiseUtils.mjs"
|
|
114
|
+
},
|
|
111
115
|
"./fileManager": {
|
|
112
116
|
"require": "./dist/v1/fileManager/index.cjs",
|
|
113
117
|
"import": "./dist/v1/fileManager/index.mjs"
|
|
@@ -140,6 +144,10 @@
|
|
|
140
144
|
"require": "./dist/v1/libs/TinyMediaPlayer/Youtube.cjs",
|
|
141
145
|
"import": "./dist/v1/libs/TinyMediaPlayer/Youtube.mjs"
|
|
142
146
|
},
|
|
147
|
+
"./libs/TinyMediaPlayer/SoundCloud": {
|
|
148
|
+
"require": "./dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs",
|
|
149
|
+
"import": "./dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs"
|
|
150
|
+
},
|
|
143
151
|
"./libs/TinyMediaPlayer/HtmlAudio": {
|
|
144
152
|
"require": "./dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs",
|
|
145
153
|
"import": "./dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs"
|
|
@@ -152,6 +160,10 @@
|
|
|
152
160
|
"require": "./dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.cjs",
|
|
153
161
|
"import": "./dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.mjs"
|
|
154
162
|
},
|
|
163
|
+
"./libs/TinyMediaPlayer/docs/SoundCloudWidget": {
|
|
164
|
+
"require": "./dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.cjs",
|
|
165
|
+
"import": "./dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.mjs"
|
|
166
|
+
},
|
|
155
167
|
"./libs/TinyRadioFm": {
|
|
156
168
|
"require": "./dist/v1/libs/TinyRadioFm.cjs",
|
|
157
169
|
"import": "./dist/v1/libs/TinyRadioFm.mjs"
|
|
@@ -503,23 +515,16 @@
|
|
|
503
515
|
},
|
|
504
516
|
"keywords": [
|
|
505
517
|
"tiny-essentials",
|
|
506
|
-
"
|
|
518
|
+
"utility-library",
|
|
507
519
|
"storage",
|
|
508
520
|
"text-editor",
|
|
509
521
|
"color-converter",
|
|
510
522
|
"clock",
|
|
511
523
|
"time",
|
|
512
|
-
"text",
|
|
513
|
-
"text-range",
|
|
514
|
-
"input-editor",
|
|
515
|
-
"string-utils",
|
|
516
524
|
"string-manipulation",
|
|
517
525
|
"obj-type",
|
|
518
526
|
"type-checker",
|
|
519
|
-
"simple-math",
|
|
520
|
-
"math-utils",
|
|
521
527
|
"shuffle-array",
|
|
522
|
-
"array-utils",
|
|
523
528
|
"json",
|
|
524
529
|
"json-utils",
|
|
525
530
|
"json-color",
|
|
@@ -536,7 +541,47 @@
|
|
|
536
541
|
"toolkit",
|
|
537
542
|
"frontend-utils",
|
|
538
543
|
"backend-utils",
|
|
539
|
-
"nodejs-utils"
|
|
544
|
+
"nodejs-utils",
|
|
545
|
+
"array-utils",
|
|
546
|
+
"object-utils",
|
|
547
|
+
"string-utils",
|
|
548
|
+
"math-utils",
|
|
549
|
+
"dom-utils",
|
|
550
|
+
"html-utils",
|
|
551
|
+
"css-utils",
|
|
552
|
+
"modular-scripts",
|
|
553
|
+
"type-validation",
|
|
554
|
+
"text-manipulation",
|
|
555
|
+
"text-formatting",
|
|
556
|
+
"color-management",
|
|
557
|
+
"color-conversion",
|
|
558
|
+
"color-validation",
|
|
559
|
+
"drag-and-drop",
|
|
560
|
+
"scroll-management",
|
|
561
|
+
"clipboard-management",
|
|
562
|
+
"notifications",
|
|
563
|
+
"toast-notifications",
|
|
564
|
+
"loading-screen",
|
|
565
|
+
"cookie-consent",
|
|
566
|
+
"i18n",
|
|
567
|
+
"iframe-communication",
|
|
568
|
+
"window-communication",
|
|
569
|
+
"media-playback",
|
|
570
|
+
"audio-processing",
|
|
571
|
+
"gamepad-api",
|
|
572
|
+
"input-handling",
|
|
573
|
+
"file-upload",
|
|
574
|
+
"inventory-management",
|
|
575
|
+
"level-up-system",
|
|
576
|
+
"raffle-system",
|
|
577
|
+
"day-night-cycle",
|
|
578
|
+
"rate-limiting",
|
|
579
|
+
"promise-queue",
|
|
580
|
+
"file-management",
|
|
581
|
+
"terminal-ui",
|
|
582
|
+
"json-formatting",
|
|
583
|
+
"fuzzy-logic",
|
|
584
|
+
"text-range-editor"
|
|
540
585
|
],
|
|
541
586
|
"author": "Yasmin Seidel (Jasmin Dreasond)",
|
|
542
587
|
"license": "LGPL-3.0-only",
|