tiny-essentials 1.28.7 → 1.28.8
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/changelog/1/28/8.md +17 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDebugger.min.js +1 -0
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/browserDetector.cjs +228 -0
- package/dist/v1/basics/browserDetector.d.mts +66 -0
- package/dist/v1/basics/browserDetector.mjs +207 -0
- package/dist/v1/basics/index.cjs +6 -0
- package/dist/v1/basics/index.d.mts +2 -1
- package/dist/v1/basics/index.mjs +2 -1
- package/dist/v1/build/TinyDebugger.cjs +7 -0
- package/dist/v1/build/TinyDebugger.d.mts +3 -0
- package/dist/v1/build/TinyDebugger.mjs +2 -0
- package/dist/v1/index.cjs +8 -0
- package/dist/v1/index.d.mts +3 -1
- package/dist/v1/index.mjs +4 -2
- package/dist/v1/libs/TinyDebugger.cjs +380 -0
- package/dist/v1/libs/TinyDebugger.d.mts +132 -0
- package/dist/v1/libs/TinyDebugger.mjs +351 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +39 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +35 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +39 -3
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +35 -3
- package/dist/v1/libs/TinyMediaPlayer/Mock.cjs +333 -0
- package/dist/v1/libs/TinyMediaPlayer/Mock.d.mts +154 -0
- package/dist/v1/libs/TinyMediaPlayer/Mock.mjs +296 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +30 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +26 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +39 -3
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +32 -3
- package/dist/v1/libs/TinyMediaPlayer/index.cjs +18 -0
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +16 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +156 -31
- package/dist/v1/libs/TinyMediaPlayer.d.mts +43 -7
- package/dist/v1/libs/TinyMediaPlayer.mjs +148 -31
- package/dist/v1/libs/TinyPromiseQueue.cjs +6 -4
- package/dist/v1/libs/TinyPromiseQueue.d.mts +8 -6
- package/dist/v1/libs/TinyPromiseQueue.mjs +6 -4
- package/dist/v1/libs/TinyRadioFm.cjs +271 -138
- package/dist/v1/libs/TinyRadioFm.d.mts +67 -3
- package/dist/v1/libs/TinyRadioFm.mjs +239 -123
- package/docs/v1/libs/TinyMediaPlayer.md +25 -21
- package/docs/v1/libs/TinyRadioFm.md +25 -3
- package/package.json +9 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🎧 TinyMediaPlayer Documentation
|
|
2
2
|
|
|
3
|
-
`TinyMediaPlayer` is a robust, universal media player manager designed to orchestrate playback across multiple different media providers (such as YouTube, Spotify, etc.) using an **Adapter Pattern**.
|
|
3
|
+
`TinyMediaPlayer` is a robust, universal media player manager designed to orchestrate playback across multiple different media providers (such as YouTube, Spotify, etc.) using an **Adapter Pattern**. It inherits debugging capabilities from `TinyDebugger`.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -11,33 +11,31 @@ To support different media platforms, `TinyMediaPlayer` relies on **Adapters**.
|
|
|
11
11
|
### 🛠️ `BaseMediaAdapter` (Abstract Class)
|
|
12
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
14
|
#### Methods
|
|
20
15
|
| Method | Description | Parameters | Returns |
|
|
21
16
|
| :--- | :--- | :--- | :--- |
|
|
17
|
+
| `static canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
|
|
22
18
|
| `canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
|
|
23
19
|
| `isReady` | Synchronously checks if the adapter is ready. | None | `boolean` |
|
|
20
|
+
| `isPaused` | Checks whether the media adapter is paused. | None | `boolean` |
|
|
21
|
+
| `isEnded` | Checks whether the media adapter is ended. | None | `boolean` |
|
|
24
22
|
| `waitIsReady` | Asynchronously waits until the adapter is ready. | None | `Promise<void>` |
|
|
25
23
|
| `play` | Starts or resumes playback of the provided content. | `content: MediaContent` | `Promise<void>` |
|
|
26
24
|
| `pause` | Pauses the current playback. | None | `Promise<void>` |
|
|
27
|
-
| `stop` | Stops the playback completely and resets the platform state. | None | `Promise<void>` |
|
|
25
|
+
| `stop` | Stops the playback completely and resets the internal platform state. | None | `Promise<void>` |
|
|
28
26
|
| `seek` | Seeks to a specific time in the media timeline. | `timeMs: number` | `Promise<void>` |
|
|
29
27
|
| `isMuted` | Checks whether the player is currently muted. | None | `boolean \| null` |
|
|
30
28
|
| `mute` | Mutes the current playback. | None | `Promise<void>` |
|
|
31
29
|
| `unMute` | Unmutes the current playback. | None | `Promise<void>` |
|
|
32
|
-
| `getCurrentTime` | Retrieves the current playback
|
|
30
|
+
| `getCurrentTime` | Retrieves the current playback time from the underlying API. | None | `number` (ms) |
|
|
33
31
|
| `getTotalDuration` | Gets the total duration of the content. | None | `number` (ms) |
|
|
34
32
|
| `getRemainingTime` | Gets the remaining time until the content ends. | None | `number` (ms) |
|
|
35
33
|
| `getPlaybackPercentage` | Gets the percentage of the content that has been played. | None | `number` (0 to 100) |
|
|
36
34
|
| `getTimeData` | Retrieves a consolidated object containing all time-related metrics. | None | `ContentTimeData` |
|
|
37
35
|
| `setVolume` | Sets the playback volume for the underlying API. | `volume: number` (0.0 to 1.0) | `void` |
|
|
38
|
-
| `getVolume` | Gets the
|
|
39
|
-
| `getContentData` | Retrieves the metadata of the loaded content. | None | `Promise<ContentData>` |
|
|
40
|
-
| `destroy` | Cleans up the instance
|
|
36
|
+
| `getVolume` | Gets the playback volume from the underlying API. | None | `number` (0.0 to 1.0) |
|
|
37
|
+
| `getContentData` | Retrieves the metadata of the currently loaded content. | None | `Promise<ContentData>` |
|
|
38
|
+
| `destroy` | Cleans up the instance. | None | `void` |
|
|
41
39
|
|
|
42
40
|
---
|
|
43
41
|
|
|
@@ -90,11 +88,6 @@ import { BaseMediaAdapter } from 'tiny-essentials/libs/TinyMediaPlayer/Base';
|
|
|
90
88
|
* @extends BaseMediaAdapter
|
|
91
89
|
*/
|
|
92
90
|
class MyCustomServiceAdapter extends BaseMediaAdapter {
|
|
93
|
-
/**
|
|
94
|
-
* Determines if this adapter can play the given content.
|
|
95
|
-
* @param {MediaContent} content - The media content to check.
|
|
96
|
-
* @returns {boolean} - True if the URL matches the service.
|
|
97
|
-
*/
|
|
98
91
|
static canHandle(content) {
|
|
99
92
|
return content.url.startsWith('https://example.com/');
|
|
100
93
|
}
|
|
@@ -116,6 +109,8 @@ class MyCustomServiceAdapter extends BaseMediaAdapter {
|
|
|
116
109
|
async getContentData() { return {}; }
|
|
117
110
|
async waitIsReady() {}
|
|
118
111
|
isReady() { return true; }
|
|
112
|
+
isPaused() { return false; }
|
|
113
|
+
isEnded() { return false; }
|
|
119
114
|
isMuted() { return false; }
|
|
120
115
|
async mute() {}
|
|
121
116
|
async unMute() {}
|
|
@@ -123,6 +118,7 @@ class MyCustomServiceAdapter extends BaseMediaAdapter {
|
|
|
123
118
|
getRemainingTime() { return 0; }
|
|
124
119
|
getPlaybackPercentage() { return 0; }
|
|
125
120
|
getTimeData() { return {}; }
|
|
121
|
+
destroy() {}
|
|
126
122
|
}
|
|
127
123
|
|
|
128
124
|
// Registering the custom adapter
|
|
@@ -166,6 +162,9 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
166
162
|
* **`repeatCurrentOnPrev`** (`boolean`): If `true`, clicking 'previous' repeats the current track on the first click. (Default: `false`).
|
|
167
163
|
* **`smoothPlayPauseVolume`** (`boolean`): If `true`, volume fades smoothly during play/pause transitions. (Default: `false`).
|
|
168
164
|
* **`smoothStopVolume`** (`boolean`): If `true`, volume fades smoothly to zero when stopping. (Default: `false`).
|
|
165
|
+
* **`debugMode`** (`boolean`): Whether to enable internal debug logging.
|
|
166
|
+
* **`useLogColors`** (`boolean`): Whether to enable log color support.
|
|
167
|
+
* **`logger`** (`Console`): A custom logger object.
|
|
169
168
|
|
|
170
169
|
---
|
|
171
170
|
|
|
@@ -204,7 +203,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
204
203
|
| `isRandom` | `boolean` | Enables or disables shuffle mode. |
|
|
205
204
|
| `isPlaying` | `boolean` | Indicates if media is currently playing. |
|
|
206
205
|
| `volume` | `number` | The current volume level (strictly between `0.0` and `1.0`). |
|
|
207
|
-
| `isMuted` | `boolean` |
|
|
206
|
+
| `isMuted` | `boolean` | Indicates if the player is currently muted. |
|
|
208
207
|
|
|
209
208
|
#### 🎨 UX & Customization
|
|
210
209
|
| Property | Type | Description |
|
|
@@ -261,9 +260,12 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
261
260
|
#### ⏯️ Playback Controls
|
|
262
261
|
* **`play()`**: **(Async)** Starts playback of the current track.
|
|
263
262
|
* **`pause()`**: **(Async)** Pauses the current track.
|
|
263
|
+
* **`mute()`**: **(Async)** Mutes the playback.
|
|
264
|
+
* **`unMute()`**: **(Async)** Unmutes the playback.
|
|
264
265
|
* **`stop()`**: **(Async)** Stops the current track completely.
|
|
265
266
|
* **`next()`**: **(Async)** Advances to the next track (respects `loopMode` and `isRandom`).
|
|
266
267
|
* **`prev()`**: **(Async)** Returns to the previous track (respects `loopMode` and `isRandom`).
|
|
268
|
+
* **`skipTo(index)`**: **(Async)** Jumps to a specific index in the playlist.
|
|
267
269
|
* **`seek(timeMs)`**: **(Async)** Jumps to a specific millisecond in the current track.
|
|
268
270
|
* **`step(stepMs)`**: **(Async)** Moves the timeline forward (+) or backward (-) by `stepMs`.
|
|
269
271
|
|
|
@@ -272,11 +274,13 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
272
274
|
* **`getTotalDuration()`**: Gets the total duration of the current track in milliseconds.
|
|
273
275
|
* **`getRemainingTime()`**: Gets the remaining time until the current track ends in milliseconds.
|
|
274
276
|
* **`getPlaybackPercentage()`**: Gets the percentage of the current track that has been played (0-100).
|
|
275
|
-
* **`
|
|
277
|
+
* **`isPaused` (Getter)**: Checks if the adapter is paused.
|
|
278
|
+
* **`isEnded` (Getter)**: Checks if the adapter has ended.
|
|
279
|
+
* **`getContentData()`**: **(Async)** Retrieves structured metadata for the current content.
|
|
276
280
|
* **`waitIsReady()`**: **(Async)** Waits until the active adapter is fully initialized.
|
|
277
281
|
|
|
278
282
|
#### ♻️ Lifecycle
|
|
279
|
-
* **`destroy()`**: **(Async)** Safely stops playback, clears state, removes adapters, and detaches all listeners
|
|
283
|
+
* **`destroy()`**: **(Async)** Safely stops playback, clears state, removes adapters, and detaches all listeners.
|
|
280
284
|
|
|
281
285
|
---
|
|
282
286
|
|
|
@@ -318,6 +322,6 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
318
322
|
## ⚠️ Error Handling
|
|
319
323
|
|
|
320
324
|
The class uses strict validation. The following errors may be thrown:
|
|
321
|
-
* **`TypeError`**: Thrown when an argument is of the wrong type
|
|
322
|
-
* **`RangeError`**: Thrown when a number is out of allowed bounds
|
|
325
|
+
* **`TypeError`**: Thrown when an argument is of the wrong type.
|
|
326
|
+
* **`RangeError`**: Thrown when a number is out of allowed bounds.
|
|
323
327
|
* **`Error`**: Thrown if no compatible adapter is found for the current content.
|
|
@@ -31,7 +31,9 @@ The behavior of the engine is controlled via the `RadioConfig` object.
|
|
|
31
31
|
| `voiceAfterMusic` | `boolean` | `true` | If `true`, voice messages play after music tracks. |
|
|
32
32
|
| `voiceMin` | `number` | `0` | Minimum number of voice messages to play in a cycle. |
|
|
33
33
|
| `voiceMax` | `number` | `1` | Maximum number of voice messages to play in a cycle. |
|
|
34
|
+
| `musicMinConsecutive`| `number` | `0` | Min times a music track must repeat consecutively. |
|
|
34
35
|
| `musicMaxConsecutive`| `number` | `0` | Max consecutive music repeats (`-1` = unlimited, `0` = no repeats). |
|
|
36
|
+
| `voiceMinConsecutive`| `number` | `0` | Min times a voice track must repeat consecutively. |
|
|
35
37
|
| `voiceMaxConsecutive`| `number` | `0` | Max consecutive voice repeats (`-1` = unlimited, `0` = no repeats). |
|
|
36
38
|
|
|
37
39
|
---
|
|
@@ -60,7 +62,7 @@ Adds new content to the engine immediately.
|
|
|
60
62
|
* **Parameters:**
|
|
61
63
|
* `type`: `'music' | 'voice' | 'custom'`.
|
|
62
64
|
* `data`: The `MediaContent` object (must include `id` and `duration`).
|
|
63
|
-
* `smartQueue`: If `true`, delays insertion until the
|
|
65
|
+
* `smartQueue`: If `true`, delays insertion until the end of the content playing at that timestamp (primarily for `custom`).
|
|
64
66
|
* **Emits:** `contentAdded`
|
|
65
67
|
|
|
66
68
|
#### `remove(id)`
|
|
@@ -108,7 +110,7 @@ Predicts upcoming events from a specific date forward using a virtual sandbox to
|
|
|
108
110
|
### 💾 Persistence & Lifecycle
|
|
109
111
|
|
|
110
112
|
#### `async exportState()`
|
|
111
|
-
Exports the entire radio state (playlists, tasks, seed, config) as a JSON string. Automatically converts all image Blob URLs to **Base64** for
|
|
113
|
+
Exports the entire radio state (playlists, tasks, seed, config) as a JSON string. Automatically converts all image Blob URLs to **Base64** for easy storage.
|
|
112
114
|
* **Returns:** `Promise<string>`
|
|
113
115
|
|
|
114
116
|
#### `importState(json)`
|
|
@@ -138,4 +140,24 @@ An instruction to change the radio state.
|
|
|
138
140
|
* `timestamp`: Execution time.
|
|
139
141
|
* `action`: `'add' | 'remove' | 'move'`.
|
|
140
142
|
* `type`: `'music' | 'voice'`.
|
|
141
|
-
* `payload`: Action-specific data.
|
|
143
|
+
* `payload`: Action-specific data (`MediaContent`, `string`, or `ScheduledMovePayload`).
|
|
144
|
+
|
|
145
|
+
### `CustomPosition` 📍
|
|
146
|
+
Represents content injected at a specific absolute timestamp.
|
|
147
|
+
* `content`: The `MediaContent` object.
|
|
148
|
+
* `intendedTimestamp`: The target absolute timestamp.
|
|
149
|
+
* `originalTimestamp`: The timestamp preserved for intelligent repositioning.
|
|
150
|
+
|
|
151
|
+
### `ScheduledMovePayload` 🚚
|
|
152
|
+
Data required to relocate an existing item within a playlist.
|
|
153
|
+
* `id`: Content ID to move.
|
|
154
|
+
* `newIndex`: The target index in the playlist.
|
|
155
|
+
|
|
156
|
+
### `CycleBlock` 🔄
|
|
157
|
+
A structural block representing a single full iteration of the radio sequence.
|
|
158
|
+
* `items`: Items belonging to this cycle.
|
|
159
|
+
* `duration`: Total duration of the cycle block in ms.
|
|
160
|
+
* `lastMusicId`: ID of the last music played in this block.
|
|
161
|
+
* `musicConsecutiveCount`: Current consecutive count for music.
|
|
162
|
+
* `lastVoiceId`: ID of the last voice played in this block.
|
|
163
|
+
* `voiceConsecutiveCount`: Current consecutive count for voice.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.8",
|
|
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"
|
|
@@ -156,6 +156,10 @@
|
|
|
156
156
|
"require": "./dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs",
|
|
157
157
|
"import": "./dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs"
|
|
158
158
|
},
|
|
159
|
+
"./libs/TinyMediaPlayer/Mock": {
|
|
160
|
+
"require": "./dist/v1/libs/TinyMediaPlayer/Mock.cjs",
|
|
161
|
+
"import": "./dist/v1/libs/TinyMediaPlayer/Mock.mjs"
|
|
162
|
+
},
|
|
159
163
|
"./libs/TinyMediaPlayer/docs/YouTubePlayer": {
|
|
160
164
|
"require": "./dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.cjs",
|
|
161
165
|
"import": "./dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.mjs"
|
|
@@ -168,6 +172,10 @@
|
|
|
168
172
|
"require": "./dist/v1/libs/TinyRadioFm.cjs",
|
|
169
173
|
"import": "./dist/v1/libs/TinyRadioFm.mjs"
|
|
170
174
|
},
|
|
175
|
+
"./libs/TinyDebugger": {
|
|
176
|
+
"require": "./dist/v1/libs/TinyDebugger.cjs",
|
|
177
|
+
"import": "./dist/v1/libs/TinyDebugger.mjs"
|
|
178
|
+
},
|
|
171
179
|
"./libs/UltraRandomMsgGen": {
|
|
172
180
|
"require": "./dist/v1/libs/UltraRandomMsgGen.cjs",
|
|
173
181
|
"import": "./dist/v1/libs/UltraRandomMsgGen.mjs"
|