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
|
@@ -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.
|
|
@@ -1223,6 +1224,43 @@ class TinyMediaPlayer extends EventEmitter {
|
|
|
1223
1224
|
return 0;
|
|
1224
1225
|
}
|
|
1225
1226
|
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
1229
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
1230
|
+
* @returns {Promise<ContentData>}
|
|
1231
|
+
*/
|
|
1232
|
+
async getContentData() {
|
|
1233
|
+
checkDestroy(this.#destroyed);
|
|
1234
|
+
const defaultData = {
|
|
1235
|
+
id: '',
|
|
1236
|
+
createdAt: '',
|
|
1237
|
+
artistId: '',
|
|
1238
|
+
artistName: '',
|
|
1239
|
+
description: '',
|
|
1240
|
+
title: '',
|
|
1241
|
+
duration: 0,
|
|
1242
|
+
avatar: '',
|
|
1243
|
+
url: '',
|
|
1244
|
+
};
|
|
1245
|
+
try {
|
|
1246
|
+
const adapter = this.#getActiveAdapter();
|
|
1247
|
+
return adapter ? adapter.getContentData() : defaultData;
|
|
1248
|
+
}
|
|
1249
|
+
catch {
|
|
1250
|
+
return defaultData;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
1255
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
1256
|
+
*/
|
|
1257
|
+
async waitIsReady() {
|
|
1258
|
+
checkDestroy(this.#destroyed);
|
|
1259
|
+
const adapter = this.#getActiveAdapter();
|
|
1260
|
+
if (!adapter)
|
|
1261
|
+
return;
|
|
1262
|
+
return adapter.waitIsReady();
|
|
1263
|
+
}
|
|
1226
1264
|
// ==========================================
|
|
1227
1265
|
// DESTROYER
|
|
1228
1266
|
// ==========================================
|
|
@@ -9,17 +9,29 @@
|
|
|
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
|
-
| `play` | Starts or resumes playback. | `content: MediaContent` | `Promise<void>` |
|
|
22
|
+
| `canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
|
|
23
|
+
| `play` | Starts or resumes playback of the provided content. | `content: MediaContent` | `Promise<void>` |
|
|
18
24
|
| `pause` | Pauses the current playback. | None | `Promise<void>` |
|
|
19
|
-
| `stop` | Stops playback and resets the platform state. | None | `Promise<void>` |
|
|
20
|
-
| `seek` |
|
|
21
|
-
| `getCurrentTime` |
|
|
22
|
-
| `
|
|
25
|
+
| `stop` | Stops the playback completely and resets the platform state. | None | `Promise<void>` |
|
|
26
|
+
| `seek` | Seeks to a specific time in the media timeline. | `timeMs: number` | `Promise<void>` |
|
|
27
|
+
| `getCurrentTime` | Retrieves the current playback position. | None | `number` (ms) |
|
|
28
|
+
| `getTotalDuration` | Gets the total duration of the content. | None | `number` (ms) |
|
|
29
|
+
| `getRemainingTime` | Gets the remaining time until the content ends. | None | `number` (ms) |
|
|
30
|
+
| `getPlaybackPercentage` | Gets the percentage of the content that has been played. | None | `number` (0 to 100) |
|
|
31
|
+
| `getTimeData` | Retrieves a consolidated object containing all time-related metrics. | None | `ContentTimeData` |
|
|
32
|
+
| `setVolume` | Sets the playback volume for the underlying API. | `volume: number` (0.0 to 1.0) | `void` |
|
|
33
|
+
| `getVolume` | Gets the current playback volume. | None | `number` (0.0 to 1.0) |
|
|
34
|
+
| `destroy` | Cleans up the instance, removes listeners, and marks it as destroyed. | None | `void` |
|
|
23
35
|
|
|
24
36
|
---
|
|
25
37
|
|
|
@@ -31,7 +43,8 @@ You can integrate `TinyMediaPlayer` into your project using two methods: using t
|
|
|
31
43
|
The library provides several optimized adapters for common media sources. You can import them and register them directly with your player instance.
|
|
32
44
|
|
|
33
45
|
**Available Adapters:**
|
|
34
|
-
* `YoutubeMediaAdapter` from `tiny-essentials/libs/TinyMediaPlayer/Youtube`
|
|
46
|
+
* `YoutubeMediaAdapter` from `tiny-essentials/libs/TinyMediaPlayer/Youtube` (https://www.youtube.com/watch?v=XXXXXXXXXXX)
|
|
47
|
+
* `SoundCloudMediaAdapter` from `tiny-essentials/libs/TinyMediaPlayer/SoundCloud` (https://api.soundcloud.com/tracks/XXXXXXXXX (From SoundCloud Embed))
|
|
35
48
|
* `HtmlAudioAdapter` from `tiny-essentials/libs/TinyMediaPlayer/HtmlAudio`
|
|
36
49
|
* `HtmlVideoAdapter` from `tiny-essentials/libs/TinyMediaPlayer/HtmlVideo`
|
|
37
50
|
|
|
@@ -76,10 +89,19 @@ class MyCustomServiceAdapter extends BaseMediaAdapter {
|
|
|
76
89
|
* @param {MediaContent} content - The media content to check.
|
|
77
90
|
* @returns {boolean} - True if the URL matches the service.
|
|
78
91
|
*/
|
|
79
|
-
canHandle(content) {
|
|
92
|
+
static canHandle(content) {
|
|
80
93
|
return content.url.startsWith('https://example.com/');
|
|
81
94
|
}
|
|
82
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Determines if this adapter can play the given content.
|
|
98
|
+
* @param {MediaContent} content - The media content to check.
|
|
99
|
+
* @returns {boolean} - True if the URL matches the service.
|
|
100
|
+
*/
|
|
101
|
+
canHandle(content) {
|
|
102
|
+
return MyCustomServiceAdapter.canHandle(content);
|
|
103
|
+
}
|
|
104
|
+
|
|
83
105
|
/**
|
|
84
106
|
* Starts playback for the provided content.
|
|
85
107
|
* @param {MediaContent} content - The content to play.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.6",
|
|
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"
|
|
@@ -503,23 +511,16 @@
|
|
|
503
511
|
},
|
|
504
512
|
"keywords": [
|
|
505
513
|
"tiny-essentials",
|
|
506
|
-
"
|
|
514
|
+
"utility-library",
|
|
507
515
|
"storage",
|
|
508
516
|
"text-editor",
|
|
509
517
|
"color-converter",
|
|
510
518
|
"clock",
|
|
511
519
|
"time",
|
|
512
|
-
"text",
|
|
513
|
-
"text-range",
|
|
514
|
-
"input-editor",
|
|
515
|
-
"string-utils",
|
|
516
520
|
"string-manipulation",
|
|
517
521
|
"obj-type",
|
|
518
522
|
"type-checker",
|
|
519
|
-
"simple-math",
|
|
520
|
-
"math-utils",
|
|
521
523
|
"shuffle-array",
|
|
522
|
-
"array-utils",
|
|
523
524
|
"json",
|
|
524
525
|
"json-utils",
|
|
525
526
|
"json-color",
|
|
@@ -536,7 +537,47 @@
|
|
|
536
537
|
"toolkit",
|
|
537
538
|
"frontend-utils",
|
|
538
539
|
"backend-utils",
|
|
539
|
-
"nodejs-utils"
|
|
540
|
+
"nodejs-utils",
|
|
541
|
+
"array-utils",
|
|
542
|
+
"object-utils",
|
|
543
|
+
"string-utils",
|
|
544
|
+
"math-utils",
|
|
545
|
+
"dom-utils",
|
|
546
|
+
"html-utils",
|
|
547
|
+
"css-utils",
|
|
548
|
+
"modular-scripts",
|
|
549
|
+
"type-validation",
|
|
550
|
+
"text-manipulation",
|
|
551
|
+
"text-formatting",
|
|
552
|
+
"color-management",
|
|
553
|
+
"color-conversion",
|
|
554
|
+
"color-validation",
|
|
555
|
+
"drag-and-drop",
|
|
556
|
+
"scroll-management",
|
|
557
|
+
"clipboard-management",
|
|
558
|
+
"notifications",
|
|
559
|
+
"toast-notifications",
|
|
560
|
+
"loading-screen",
|
|
561
|
+
"cookie-consent",
|
|
562
|
+
"i18n",
|
|
563
|
+
"iframe-communication",
|
|
564
|
+
"window-communication",
|
|
565
|
+
"media-playback",
|
|
566
|
+
"audio-processing",
|
|
567
|
+
"gamepad-api",
|
|
568
|
+
"input-handling",
|
|
569
|
+
"file-upload",
|
|
570
|
+
"inventory-management",
|
|
571
|
+
"level-up-system",
|
|
572
|
+
"raffle-system",
|
|
573
|
+
"day-night-cycle",
|
|
574
|
+
"rate-limiting",
|
|
575
|
+
"promise-queue",
|
|
576
|
+
"file-management",
|
|
577
|
+
"terminal-ui",
|
|
578
|
+
"json-formatting",
|
|
579
|
+
"fuzzy-logic",
|
|
580
|
+
"text-range-editor"
|
|
540
581
|
],
|
|
541
582
|
"author": "Yasmin Seidel (Jasmin Dreasond)",
|
|
542
583
|
"license": "LGPL-3.0-only",
|