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,381 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* https://developers.soundcloud.com/docs/api/html5-widget
|
|
5
|
+
* @fileoverview JSDoc type definitions for the SoundCloud IFrame Player API.
|
|
6
|
+
* This file provides full IntelliSense/autocomplete for the global `window.SC` object.
|
|
7
|
+
* @module youtube-api-docs
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} SoundObject
|
|
12
|
+
* @property {string} title - The title of the track.
|
|
13
|
+
* @property {number} duration - Total duration of the track in milliseconds.
|
|
14
|
+
* @property {string} artwork_url - The URL of the track's cover art image.
|
|
15
|
+
* @property {string} caption - A short descriptive caption for the track.
|
|
16
|
+
* @property {number} comment_count - The total number of comments on the track.
|
|
17
|
+
* @property {boolean} commentable - Indicates if users are allowed to comment on this track.
|
|
18
|
+
* @property {string} created_at - ISO 8601 timestamp of when the track was created.
|
|
19
|
+
* @property {string} description - The full text description of the track.
|
|
20
|
+
* @property {string} display_date - A human-readable string representing the date.
|
|
21
|
+
* @property {number} download_count - The total number of times the track has been downloaded.
|
|
22
|
+
* @property {boolean} downloadable - Indicates if the track is available for download.
|
|
23
|
+
* @property {string} embeddable_by - Information regarding the permissions for embedding the track.
|
|
24
|
+
* @property {number} full_duration - The complete duration of the track in milliseconds.
|
|
25
|
+
* @property {string} genre - The musical genre assigned to the track.
|
|
26
|
+
* @property {boolean} has_downloads_left - Indicates if the user has remaining download credits.
|
|
27
|
+
* @property {number} id - The unique numerical identifier for the sound.
|
|
28
|
+
* @property {string} kind - The type of resource (e.g., 'track').
|
|
29
|
+
* @property {string} label_name - The name of the record label associated with the track.
|
|
30
|
+
* @property {string} last_modified - ISO 8601 timestamp of the last time the track was modified.
|
|
31
|
+
* @property {string} license - The licensing terms applied to the track.
|
|
32
|
+
* @property {number} likes_count - The total number of likes the track has received.
|
|
33
|
+
* @property {string} monetization_model - The specific model used for track monetization.
|
|
34
|
+
* @property {string} permalink - The unique URL slug for the track.
|
|
35
|
+
* @property {string} permalink_url - The full URL of the track's permalink.
|
|
36
|
+
* @property {boolean} playable - Indicates if the track is currently playable.
|
|
37
|
+
* @property {number} playback_count - The total number of times the track has been played.
|
|
38
|
+
* @property {string} policy - The usage policy governing the track.
|
|
39
|
+
* @property {boolean} public - Indicates if the track is accessible to the public.
|
|
40
|
+
* @property {string} purchase_title - The title used when purchasing the track.
|
|
41
|
+
* @property {string} purchase_url - The URL used to purchase the track.
|
|
42
|
+
* @property {string} release_date - The official release date of the track.
|
|
43
|
+
* @property {number} reposts_count - The total number of times the track has been reposted.
|
|
44
|
+
* @property {string} resource_type - The category of the resource.
|
|
45
|
+
* @property {string} secret_token - A token required to access private or restricted tracks.
|
|
46
|
+
* @property {string} sharing - Information regarding the sharing status or permissions.
|
|
47
|
+
* @property {string} state - The current playback or availability state of the track.
|
|
48
|
+
* @property {string} station_permalink - The permalink for the associated station.
|
|
49
|
+
* @property {string} station_urn - The Uniform Resource Name for the associated station.
|
|
50
|
+
* @property {boolean} streamable - Indicates if the track can be streamed.
|
|
51
|
+
* @property {string} tag_list - A list of tags associated with the track.
|
|
52
|
+
* @property {string} track_authorization - Authorization details for accessing the track.
|
|
53
|
+
* @property {string} uri - The Uniform Resource Identifier for the track.
|
|
54
|
+
* @property {string} urn - The Uniform Resource Name for the track.
|
|
55
|
+
* @property {number} user_id - The unique identifier of the user who uploaded the track.
|
|
56
|
+
* @property {string} visuals - Configuration data for track visuals.
|
|
57
|
+
* @property {string} waveform_url - The URL of the track's waveform image.
|
|
58
|
+
* @property {MediaObject} media - Object containing media and transcoding information.
|
|
59
|
+
* @property {PublisherObject} publisher_metadata - Metadata regarding the track's publisher.
|
|
60
|
+
* @property {UserObject} user - Information about the user who owns the track.
|
|
61
|
+
* @property {number} _resource_id - Internal identifier for the resource.
|
|
62
|
+
* @property {string} _resource_type - Internal type identifier for the resource.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {Object} MediaObject
|
|
67
|
+
* @property {TranscodingObject[]} transcodings - An array of available audio transcoding formats.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {Object} TranscodingObject
|
|
72
|
+
* @property {{ mime_type: string, protocol: string }} format - The MIME type and protocol of the audio format.
|
|
73
|
+
* @property {number} duration - The duration of this specific transcoding in milliseconds.
|
|
74
|
+
* @property {boolean} is_legacy_transcoding - Indicates if this is an older, legacy transcoding format.
|
|
75
|
+
* @property {string} preset - The preset used to generate this transcoding.
|
|
76
|
+
* @property {string} quality - The audio quality level of this transcoding.
|
|
77
|
+
* @property {boolean} snipped - Indicates if this is a short preview or snippet.
|
|
78
|
+
* @property {string} url - The direct URL to the transcoded audio file.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {Object} PublisherObject
|
|
83
|
+
* @property {number} id - The unique identifier for the publisher.
|
|
84
|
+
* @property {string} urn - The Uniform Resource Name for the publisher.
|
|
85
|
+
* @property {string} artist - The name of the artist.
|
|
86
|
+
* @property {string} publisher - The name of the publishing entity.
|
|
87
|
+
* @property {string} writer_composer - The name of the writer or composer.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} UserBadgesObject
|
|
92
|
+
* @property {boolean} creator_mid_tier - Indicates if the user has mid-tier creator status.
|
|
93
|
+
* @property {boolean} pro - Indicates if the user has a Pro subscription.
|
|
94
|
+
* @property {boolean} pro_unlimited - Indicates if the user has an Unlimited subscription.
|
|
95
|
+
* @property {boolean} verified - Indicates if the user's account is verified.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {Object} CreatorSubscriptionObject
|
|
100
|
+
* @property {{ id: string }} product - An object containing the ID of the subscription product.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {Object} VisualsObject
|
|
105
|
+
* @property {boolean} enabled - Indicates if the visualizer is enabled.
|
|
106
|
+
* @property {boolean} tracking - Indicates if visualizer tracking is enabled.
|
|
107
|
+
* @property {string} urn - The Uniform Resource Name for the visualizer.
|
|
108
|
+
* @property {VisualsObjectData} visuals - The specific data for the visualizer.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @typedef {Object} VisualsObjectData
|
|
113
|
+
* @property {number} entry_time - The timestamp when the visual element starts.
|
|
114
|
+
* @property {string} urn - The Uniform Resource Name for the visual data.
|
|
115
|
+
* @property {string} visual_url - The URL of the visual asset.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {Object} UserObject
|
|
120
|
+
* @property {VisualsObject} visuals - Visualizer configuration for the user.
|
|
121
|
+
* @property {CreatorSubscriptionObject} creator_subscription - The user's current subscription product.
|
|
122
|
+
* @property {CreatorSubscriptionObject[]} creator_subscriptions - A list of all subscriptions held by the user.
|
|
123
|
+
* @property {UserBadgesObject} badges - The badges and status indicators assigned to the user.
|
|
124
|
+
* @property {string} avatar_url - The URL of the user's profile picture.
|
|
125
|
+
* @property {string} city - The city where the user is located.
|
|
126
|
+
* @property {number} comments_count - The total number of comments made by the user.
|
|
127
|
+
* @property {string} country_code - The ISO country code of the user.
|
|
128
|
+
* @property {string} created_at - ISO 8601 timestamp of when the user account was created.
|
|
129
|
+
* @property {string} date_of_birth - The user's date of birth.
|
|
130
|
+
* @property {string} description - The user's profile description.
|
|
131
|
+
* @property {string} first_name - The user's first name.
|
|
132
|
+
* @property {number} followers_count - The total number of followers the user has.
|
|
133
|
+
* @property {number} followings_count - The total number of accounts the user follows.
|
|
134
|
+
* @property {string} full_name - The user's complete name.
|
|
135
|
+
* @property {number} groups_count - The total number of groups the user belongs to.
|
|
136
|
+
* @property {number} id - The unique numerical identifier for the user.
|
|
137
|
+
* @property {string} kind - The type of resource (e.g., 'user').
|
|
138
|
+
* @property {string} last_modified - ISO 8601 timestamp of the last profile update.
|
|
139
|
+
* @property {string} last_name - The user's last name.
|
|
140
|
+
* @property {number} likes_count - The total number of likes the user has given.
|
|
141
|
+
* @property {string} permalink - The unique profile slug for the user.
|
|
142
|
+
* @property {string} permalink_url - The full URL of the user's profile.
|
|
143
|
+
* @property {number} playlist_count - The total number of playlists created by the user.
|
|
144
|
+
* @property {number} playlist_likes_count - The total number of playlists liked by the user.
|
|
145
|
+
* @property {number} reposts_count - The total number of reposts made by the user.
|
|
146
|
+
* @property {string} station_permalink - The permalink for the user's station.
|
|
147
|
+
* @property {string} station_urn - The Uniform Resource Name for the user's station.
|
|
148
|
+
* @property {number} track_count - The total number of tracks uploaded by the user.
|
|
149
|
+
* @property {string} uri - The Uniform Resource Identifier for the user.
|
|
150
|
+
* @property {string} urn - The Uniform Resource Name for the user.
|
|
151
|
+
* @property {string} username - The user's unique username.
|
|
152
|
+
* @property {boolean} verified - Indicates if the user's account is verified.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Class representing a SoundCloud Widget instance.
|
|
157
|
+
*/
|
|
158
|
+
class SoundCloudWidget {
|
|
159
|
+
// Private fields for encapsulation
|
|
160
|
+
#volume = 50;
|
|
161
|
+
#position = 0;
|
|
162
|
+
#duration = 180000; // Default 3 minutes
|
|
163
|
+
#isPaused = true;
|
|
164
|
+
#currentSoundIndex = 0;
|
|
165
|
+
/** @type {SoundObject[]} */
|
|
166
|
+
#sounds = [];
|
|
167
|
+
#listeners = new Map();
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Creates an instance of SoundCloudWidget.
|
|
171
|
+
* @param {HTMLElement|string} elementOrId - The iframe element or its ID.
|
|
172
|
+
* @throws {TypeError} If the argument is not a string or an HTMLElement.
|
|
173
|
+
*/
|
|
174
|
+
constructor(elementOrId) {
|
|
175
|
+
if (typeof elementOrId !== 'string' && !(elementOrId instanceof HTMLElement)) {
|
|
176
|
+
throw new TypeError('The argument must be an HTML element or a string ID.');
|
|
177
|
+
}
|
|
178
|
+
console.log('[Mock] SoundCloud Widget initialized.');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// --- Getters and Setters with Validation ---
|
|
182
|
+
|
|
183
|
+
/** @returns {number} The current volume level. */
|
|
184
|
+
get volume() {
|
|
185
|
+
return this.#volume;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Sets the widget volume.
|
|
190
|
+
* @param {number} value - Volume value between 0 and 100.
|
|
191
|
+
* @throws {TypeError} If value is not a number.
|
|
192
|
+
* @throws {RangeError} If value is outside the 0-100 range.
|
|
193
|
+
*/
|
|
194
|
+
set volume(value) {
|
|
195
|
+
if (typeof value !== 'number') {
|
|
196
|
+
throw new TypeError('Volume must be a number.');
|
|
197
|
+
}
|
|
198
|
+
if (value < 0 || value > 100) {
|
|
199
|
+
throw new RangeError('Volume must be between 0 and 100.');
|
|
200
|
+
}
|
|
201
|
+
this.#volume = value;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// --- Public Methods ---
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Adds a listener function for a specific event.
|
|
208
|
+
* @param {string} eventName - The name of the event.
|
|
209
|
+
* @param {Function} listener - The callback function.
|
|
210
|
+
* @throws {TypeError} If listener is not a function.
|
|
211
|
+
*/
|
|
212
|
+
bind(eventName, listener) {
|
|
213
|
+
if (typeof listener !== 'function') {
|
|
214
|
+
throw new TypeError('Listener must be a function.');
|
|
215
|
+
}
|
|
216
|
+
if (!this.#listeners.has(eventName)) {
|
|
217
|
+
this.#listeners.set(eventName, []);
|
|
218
|
+
}
|
|
219
|
+
this.#listeners.get(eventName).push(listener);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Removes all listeners for a specific event.
|
|
224
|
+
* @param {string} eventName - The name of the event.
|
|
225
|
+
*/
|
|
226
|
+
unbind(eventName) {
|
|
227
|
+
this.#listeners.delete(eventName);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Simulates loading a new widget.
|
|
232
|
+
* @param {string} url - The URL of the new widget.
|
|
233
|
+
* @param {Record<string, Function>} [options] - Configuration options.
|
|
234
|
+
*/
|
|
235
|
+
load(url, options = {}) {
|
|
236
|
+
console.log(`[Mock] Loading new widget from: ${url}`);
|
|
237
|
+
// Simulate async loading
|
|
238
|
+
setTimeout(() => {
|
|
239
|
+
this._triggerEvent('READY', {});
|
|
240
|
+
}, 500);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Plays the sound. */
|
|
244
|
+
play() {
|
|
245
|
+
this.#isPaused = false;
|
|
246
|
+
this._triggerEvent('PLAY', { currentPosition: this.#position });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Pauses the sound. */
|
|
250
|
+
pause() {
|
|
251
|
+
this.#isPaused = true;
|
|
252
|
+
this._triggerEvent('PAUSE', { currentPosition: this.#position });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Toggles the sound state. */
|
|
256
|
+
toggle() {
|
|
257
|
+
if (this.#isPaused) {
|
|
258
|
+
this.play();
|
|
259
|
+
} else {
|
|
260
|
+
this.pause();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Jumps to a specific position.
|
|
266
|
+
* @param {number} milliseconds - Position in milliseconds.
|
|
267
|
+
* @throws {TypeError} If milliseconds is not a number.
|
|
268
|
+
*/
|
|
269
|
+
seekTo(milliseconds) {
|
|
270
|
+
if (typeof milliseconds !== 'number') {
|
|
271
|
+
throw new TypeError('Position must be a number.');
|
|
272
|
+
}
|
|
273
|
+
this.#position = milliseconds;
|
|
274
|
+
this._triggerEvent('SEEK', { currentPosition: this.#position });
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Sets the volume via method.
|
|
279
|
+
* @param {number} volume - Value between 0 and 100.
|
|
280
|
+
*/
|
|
281
|
+
setVolume(volume) {
|
|
282
|
+
this.volume = volume;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Skips to the next sound. */
|
|
286
|
+
next() {
|
|
287
|
+
if (this.#currentSoundIndex < this.#sounds.length - 1) {
|
|
288
|
+
this.#currentSoundIndex++;
|
|
289
|
+
this._triggerEvent('PLAY', { currentPosition: 0 });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Skips to the previous sound. */
|
|
294
|
+
prev() {
|
|
295
|
+
if (this.#currentSoundIndex > 0) {
|
|
296
|
+
this.#currentSoundIndex--;
|
|
297
|
+
this._triggerEvent('PLAY', { currentPosition: 0 });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Jumps to a specific sound index.
|
|
303
|
+
* @param {number} soundIndex - Index starting from 0.
|
|
304
|
+
* @throws {RangeError} If index is out of bounds.
|
|
305
|
+
*/
|
|
306
|
+
skip(soundIndex) {
|
|
307
|
+
if (soundIndex < 0 || soundIndex >= this.#sounds.length) {
|
|
308
|
+
throw new RangeError('Sound index out of bounds.');
|
|
309
|
+
}
|
|
310
|
+
this.#currentSoundIndex = soundIndex;
|
|
311
|
+
this._triggerEvent('PLAY', { currentPosition: 0 });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// --- Getters (Async/Callback-based) ---
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @param {(volume: number) => void} callback - Receives the volume.
|
|
318
|
+
*/
|
|
319
|
+
getVolume(callback) {
|
|
320
|
+
callback(this.#volume);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* @param {(volume: number) => void} callback - Receives the duration.
|
|
325
|
+
*/
|
|
326
|
+
getDuration(callback) {
|
|
327
|
+
callback(this.#duration);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @param {(position: number) => void} callback - Receives the current position.
|
|
332
|
+
*/
|
|
333
|
+
getPosition(callback) {
|
|
334
|
+
callback(this.#position);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @param {(soundsData: Partial<SoundObject>[]) => void} callback - Receives the list of sounds.
|
|
339
|
+
*/
|
|
340
|
+
getSounds(callback) {
|
|
341
|
+
callback(this.#sounds);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @param {(soundData: Partial<SoundObject>) => void} callback - Receives the current sound object.
|
|
346
|
+
*/
|
|
347
|
+
getCurrentSound(callback) {
|
|
348
|
+
callback(this.#sounds[this.#currentSoundIndex]);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @param {(index: number) => void} callback - Receives the current sound index.
|
|
353
|
+
*/
|
|
354
|
+
getCurrentSoundIndex(callback) {
|
|
355
|
+
callback(this.#currentSoundIndex);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @param {(paused: boolean) => void} callback - Receives the paused status.
|
|
360
|
+
*/
|
|
361
|
+
isPaused(callback) {
|
|
362
|
+
callback(true);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// --- Internal Helpers ---
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Triggers an event and notifies listeners.
|
|
369
|
+
* @param {string} eventName
|
|
370
|
+
* @param {any} data
|
|
371
|
+
* @private
|
|
372
|
+
*/
|
|
373
|
+
_triggerEvent(eventName, data) {
|
|
374
|
+
const eventListeners = this.#listeners.get(eventName);
|
|
375
|
+
if (eventListeners) {
|
|
376
|
+
eventListeners.forEach((/** @type {(arg0: any) => any} */ listener) => listener(data));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
module.exports = SoundCloudWidget;
|