tiny-essentials 1.28.9 → 1.28.11
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/10.md +5 -0
- package/changelog/1/28/11.md +20 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.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/basics/mediaContent.cjs +8 -5
- package/dist/v1/basics/mediaContent.d.mts +5 -3
- package/dist/v1/basics/mediaContent.mjs +8 -6
- package/dist/v1/libs/TinyHtml.cjs +0 -10
- package/dist/v1/libs/TinyHtml.d.mts +0 -7
- package/dist/v1/libs/TinyHtml.mjs +0 -9
- package/dist/v1/libs/TinyMediaPlayer/index.cjs +13 -0
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +7 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +12 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +18 -2
- package/dist/v1/libs/TinyMediaPlayer.d.mts +2 -1
- package/dist/v1/libs/TinyMediaPlayer.mjs +6 -3
- package/dist/v1/libs/TinyRadioFm.cjs +10 -1
- package/dist/v1/libs/TinyRadioFm.d.mts +2 -1
- package/dist/v1/libs/TinyRadioFm.mjs +3 -2
- package/docs/v1/basics/mediaContent.md +2 -0
- package/docs/v1/libs/TinyMediaPlayer.md +5 -3
- package/docs/v1/libs/TinyRadioFm.md +2 -1
- package/package.json +1 -1
|
@@ -412,11 +412,12 @@ const valMediaContentMetadataPartial = (common) => {
|
|
|
412
412
|
*
|
|
413
413
|
* @param {string} url - The full URL of the audio file to be downloaded.
|
|
414
414
|
* @param {ParseMediaContentMetadata} parseFile - The function used to parse the file data.
|
|
415
|
-
* @
|
|
415
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
416
|
+
* @returns {Promise<MediaContentMetadata<PictureDataType>>} A promise that resolves to an object containing the extracted metadata.
|
|
416
417
|
* @throws {TypeError} If the provided `url` is not a string or `parseFile` is not a function.
|
|
417
418
|
* @throws {Error} If the network request fails or the parsing process encounters an error.
|
|
418
419
|
*/
|
|
419
|
-
const extractMediaId3Tags = async (url, parseFile) => {
|
|
420
|
+
const extractMediaId3Tags = async (url, parseFile, convertBase64toBlob = true) => {
|
|
420
421
|
// Argument Validation
|
|
421
422
|
checkString(url, 'url');
|
|
422
423
|
checkFunction(parseFile, 'parseFile');
|
|
@@ -459,7 +460,7 @@ const extractMediaId3Tags = async (url, parseFile) => {
|
|
|
459
460
|
picture:
|
|
460
461
|
common?.picture?.map((value) => ({
|
|
461
462
|
...value,
|
|
462
|
-
data: convertToBlobUrl(value.data, value.format),
|
|
463
|
+
data: convertBase64toBlob ? convertToBlobUrl(value.data, value.format) : value.data,
|
|
463
464
|
})) ?? [],
|
|
464
465
|
};
|
|
465
466
|
} catch (error) {
|
|
@@ -480,6 +481,7 @@ const extractMediaId3Tags = async (url, parseFile) => {
|
|
|
480
481
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
481
482
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
482
483
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
484
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
483
485
|
* @param {UnknownArtistGetter} unknownArtist
|
|
484
486
|
* @returns {Promise<MediaContent<PictureData>>} A promise that resolves to a valid MediaContent object.
|
|
485
487
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
@@ -520,6 +522,7 @@ const parseMediaMetadata = async (
|
|
|
520
522
|
return new Promise((resolve, reject) => reject(new TypeError('parseFile library not found.')));
|
|
521
523
|
},
|
|
522
524
|
callbacks = {},
|
|
525
|
+
convertBase64toBlob = true,
|
|
523
526
|
unknownArtist = 'null',
|
|
524
527
|
) => {
|
|
525
528
|
// Argument Validation
|
|
@@ -645,11 +648,11 @@ const parseMediaMetadata = async (
|
|
|
645
648
|
};
|
|
646
649
|
|
|
647
650
|
// 4. Automatic Metadata Extraction (ID3 Tags)
|
|
648
|
-
/** @type {Partial<MediaContentMetadata<
|
|
651
|
+
/** @type {Partial<MediaContentMetadata<PictureDataType>>} */
|
|
649
652
|
let extractedMetadata = {};
|
|
650
653
|
notifyProgress('EXTRACTING_ID3');
|
|
651
654
|
try {
|
|
652
|
-
extractedMetadata = await extractMediaId3Tags(url, parseFile);
|
|
655
|
+
extractedMetadata = await extractMediaId3Tags(url, parseFile, convertBase64toBlob);
|
|
653
656
|
} catch (err) {
|
|
654
657
|
// We treat ID3 failure as a non-fatal error for the whole process,
|
|
655
658
|
// but we still notify the developer via onError.
|
|
@@ -223,11 +223,12 @@ export declare const valMediaContentMetadataPartial: (common: Partial<ContentMet
|
|
|
223
223
|
*
|
|
224
224
|
* @param {string} url - The full URL of the audio file to be downloaded.
|
|
225
225
|
* @param {ParseMediaContentMetadata} parseFile - The function used to parse the file data.
|
|
226
|
-
* @
|
|
226
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
227
|
+
* @returns {Promise<MediaContentMetadata<PictureDataType>>} A promise that resolves to an object containing the extracted metadata.
|
|
227
228
|
* @throws {TypeError} If the provided `url` is not a string or `parseFile` is not a function.
|
|
228
229
|
* @throws {Error} If the network request fails or the parsing process encounters an error.
|
|
229
230
|
*/
|
|
230
|
-
export declare const extractMediaId3Tags: (url: string, parseFile: ParseMediaContentMetadata) => Promise<MediaContentMetadata<
|
|
231
|
+
export declare const extractMediaId3Tags: (url: string, parseFile: ParseMediaContentMetadata, convertBase64toBlob?: boolean) => Promise<MediaContentMetadata<PictureDataType>>;
|
|
231
232
|
/**
|
|
232
233
|
* A Static Factory Method that prepares a MediaContent object by
|
|
233
234
|
* extracting metadata from an audio source.
|
|
@@ -240,6 +241,7 @@ export declare const extractMediaId3Tags: (url: string, parseFile: ParseMediaCon
|
|
|
240
241
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
241
242
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
242
243
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
244
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
243
245
|
* @param {UnknownArtistGetter} unknownArtist
|
|
244
246
|
* @returns {Promise<MediaContent<PictureData>>} A promise that resolves to a valid MediaContent object.
|
|
245
247
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
@@ -280,5 +282,5 @@ export declare const parseMediaMetadata: <PictureData extends PictureDataType>(s
|
|
|
280
282
|
}, parseFile?: ParseMediaContentMetadata, callbacks?: {
|
|
281
283
|
onProgress?: (progress: LoadingMediaProgress) => void;
|
|
282
284
|
onError?: (error: MediaLoadingErrorData) => void;
|
|
283
|
-
}, unknownArtist?: UnknownArtistGetter) => Promise<MediaContent<PictureData>>;
|
|
285
|
+
}, convertBase64toBlob?: boolean, unknownArtist?: UnknownArtistGetter) => Promise<MediaContent<PictureData>>;
|
|
284
286
|
//# sourceMappingURL=mediaContent.d.mts.map
|
|
@@ -364,11 +364,12 @@ export const valMediaContentMetadataPartial = (common) => {
|
|
|
364
364
|
*
|
|
365
365
|
* @param {string} url - The full URL of the audio file to be downloaded.
|
|
366
366
|
* @param {ParseMediaContentMetadata} parseFile - The function used to parse the file data.
|
|
367
|
-
* @
|
|
367
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
368
|
+
* @returns {Promise<MediaContentMetadata<PictureDataType>>} A promise that resolves to an object containing the extracted metadata.
|
|
368
369
|
* @throws {TypeError} If the provided `url` is not a string or `parseFile` is not a function.
|
|
369
370
|
* @throws {Error} If the network request fails or the parsing process encounters an error.
|
|
370
371
|
*/
|
|
371
|
-
export const extractMediaId3Tags = async (url, parseFile) => {
|
|
372
|
+
export const extractMediaId3Tags = async (url, parseFile, convertBase64toBlob = true) => {
|
|
372
373
|
// Argument Validation
|
|
373
374
|
checkString(url, 'url');
|
|
374
375
|
checkFunction(parseFile, 'parseFile');
|
|
@@ -403,7 +404,7 @@ export const extractMediaId3Tags = async (url, parseFile) => {
|
|
|
403
404
|
track: common?.track ? { no: common.track.no, of: common.track.of } : { no: null, of: null },
|
|
404
405
|
picture: common?.picture?.map((value) => ({
|
|
405
406
|
...value,
|
|
406
|
-
data: convertToBlobUrl(value.data, value.format),
|
|
407
|
+
data: convertBase64toBlob ? convertToBlobUrl(value.data, value.format) : value.data,
|
|
407
408
|
})) ?? [],
|
|
408
409
|
};
|
|
409
410
|
}
|
|
@@ -424,6 +425,7 @@ export const extractMediaId3Tags = async (url, parseFile) => {
|
|
|
424
425
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
425
426
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
426
427
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
428
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
427
429
|
* @param {UnknownArtistGetter} unknownArtist
|
|
428
430
|
* @returns {Promise<MediaContent<PictureData>>} A promise that resolves to a valid MediaContent object.
|
|
429
431
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
@@ -459,7 +461,7 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
|
|
|
459
461
|
if (!(data instanceof Blob))
|
|
460
462
|
throw new TypeError('Expected "data" to be a Blob.');
|
|
461
463
|
return new Promise((resolve, reject) => reject(new TypeError('parseFile library not found.')));
|
|
462
|
-
}, callbacks = {}, unknownArtist = 'null') => {
|
|
464
|
+
}, callbacks = {}, convertBase64toBlob = true, unknownArtist = 'null') => {
|
|
463
465
|
// Argument Validation
|
|
464
466
|
if (typeof source !== 'string' && !(source instanceof HTMLMediaElement))
|
|
465
467
|
throw new TypeError('Source must be a string or an HTMLMediaElement.');
|
|
@@ -564,11 +566,11 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
|
|
|
564
566
|
weight: metadata.weight ?? 1,
|
|
565
567
|
};
|
|
566
568
|
// 4. Automatic Metadata Extraction (ID3 Tags)
|
|
567
|
-
/** @type {Partial<MediaContentMetadata<
|
|
569
|
+
/** @type {Partial<MediaContentMetadata<PictureDataType>>} */
|
|
568
570
|
let extractedMetadata = {};
|
|
569
571
|
notifyProgress('EXTRACTING_ID3');
|
|
570
572
|
try {
|
|
571
|
-
extractedMetadata = await extractMediaId3Tags(url, parseFile);
|
|
573
|
+
extractedMetadata = await extractMediaId3Tags(url, parseFile, convertBase64toBlob);
|
|
572
574
|
}
|
|
573
575
|
catch (err) {
|
|
574
576
|
// We treat ID3 failure as a non-fatal error for the whole process,
|
|
@@ -1042,16 +1042,6 @@ class TinyHtml {
|
|
|
1042
1042
|
return true;
|
|
1043
1043
|
}
|
|
1044
1044
|
|
|
1045
|
-
/**
|
|
1046
|
-
* @deprecated Use the getter {@link elements} instead.
|
|
1047
|
-
* Returns the current targets held by this instance.
|
|
1048
|
-
*
|
|
1049
|
-
* @returns {ConstructorElValues[]} - The instance's targets element.
|
|
1050
|
-
*/
|
|
1051
|
-
getAll() {
|
|
1052
|
-
return [...this.#el];
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
1045
|
////////////////////////////////////////////////
|
|
1056
1046
|
|
|
1057
1047
|
// TITLE: Element Getter (Private) (Pt1)
|
|
@@ -463,13 +463,6 @@ declare class TinyHtml<TinyHtmlT extends TinyHtmlConstructor> {
|
|
|
463
463
|
* @returns {boolean} - True if the element exists; otherwise, false.
|
|
464
464
|
*/
|
|
465
465
|
exists(index: number): boolean;
|
|
466
|
-
/**
|
|
467
|
-
* @deprecated Use the getter {@link elements} instead.
|
|
468
|
-
* Returns the current targets held by this instance.
|
|
469
|
-
*
|
|
470
|
-
* @returns {ConstructorElValues[]} - The instance's targets element.
|
|
471
|
-
*/
|
|
472
|
-
getAll(): ConstructorElValues[];
|
|
473
466
|
/**
|
|
474
467
|
* Returns the current Element held by this instance.
|
|
475
468
|
*
|
|
@@ -909,15 +909,6 @@ class TinyHtml {
|
|
|
909
909
|
return false;
|
|
910
910
|
return true;
|
|
911
911
|
}
|
|
912
|
-
/**
|
|
913
|
-
* @deprecated Use the getter {@link elements} instead.
|
|
914
|
-
* Returns the current targets held by this instance.
|
|
915
|
-
*
|
|
916
|
-
* @returns {ConstructorElValues[]} - The instance's targets element.
|
|
917
|
-
*/
|
|
918
|
-
getAll() {
|
|
919
|
-
return [...this.#el];
|
|
920
|
-
}
|
|
921
912
|
////////////////////////////////////////////////
|
|
922
913
|
// TITLE: Element Getter (Private) (Pt1)
|
|
923
914
|
/**
|
|
@@ -52,6 +52,19 @@ class BaseMediaAdapter extends events.EventEmitter {
|
|
|
52
52
|
return this.#destroyed;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Returns the thumbnail URL for the currently loaded track.
|
|
57
|
+
* @param {string} trackId - The SoundCloud track ID.
|
|
58
|
+
* @returns {string} The thumbnail URL.
|
|
59
|
+
* @throws {TypeError} If the trackId is not a valid string.
|
|
60
|
+
*/
|
|
61
|
+
static getThumbnailUrl(trackId) {
|
|
62
|
+
if (typeof trackId !== 'string' || trackId.trim() === '') {
|
|
63
|
+
throw new TypeError('The "trackId" must be a non-empty string.');
|
|
64
|
+
}
|
|
65
|
+
return ``;
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
/**
|
|
56
69
|
* Determines if this adapter can play the provided content.
|
|
57
70
|
* @param {MediaContent} content - The media content to evaluate.
|
|
@@ -66,6 +66,13 @@ declare class BaseMediaAdapter extends EventEmitter {
|
|
|
66
66
|
#private;
|
|
67
67
|
constructor();
|
|
68
68
|
get destroyed(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the thumbnail URL for the currently loaded track.
|
|
71
|
+
* @param {string} trackId - The SoundCloud track ID.
|
|
72
|
+
* @returns {string} The thumbnail URL.
|
|
73
|
+
* @throws {TypeError} If the trackId is not a valid string.
|
|
74
|
+
*/
|
|
75
|
+
static getThumbnailUrl(trackId: string): string;
|
|
69
76
|
/**
|
|
70
77
|
* Determines if this adapter can play the provided content.
|
|
71
78
|
* @param {MediaContent} content - The media content to evaluate.
|
|
@@ -42,6 +42,18 @@ class BaseMediaAdapter extends EventEmitter {
|
|
|
42
42
|
get destroyed() {
|
|
43
43
|
return this.#destroyed;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the thumbnail URL for the currently loaded track.
|
|
47
|
+
* @param {string} trackId - The SoundCloud track ID.
|
|
48
|
+
* @returns {string} The thumbnail URL.
|
|
49
|
+
* @throws {TypeError} If the trackId is not a valid string.
|
|
50
|
+
*/
|
|
51
|
+
static getThumbnailUrl(trackId) {
|
|
52
|
+
if (typeof trackId !== 'string' || trackId.trim() === '') {
|
|
53
|
+
throw new TypeError('The "trackId" must be a non-empty string.');
|
|
54
|
+
}
|
|
55
|
+
return ``;
|
|
56
|
+
}
|
|
45
57
|
/**
|
|
46
58
|
* Determines if this adapter can play the provided content.
|
|
47
59
|
* @param {MediaContent} content - The media content to evaluate.
|
|
@@ -88,16 +88,25 @@ class TinyMediaPlayer extends TinyDebugger {
|
|
|
88
88
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
89
89
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
90
90
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
91
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
91
92
|
* @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
|
|
92
93
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
93
94
|
*/
|
|
94
|
-
static async parseContent(
|
|
95
|
+
static async parseContent(
|
|
96
|
+
source,
|
|
97
|
+
defaultMetadata,
|
|
98
|
+
metadata,
|
|
99
|
+
parseFile,
|
|
100
|
+
callbacks,
|
|
101
|
+
convertBase64toBlob,
|
|
102
|
+
) {
|
|
95
103
|
return mediaContent.parseMediaMetadata(
|
|
96
104
|
source,
|
|
97
105
|
defaultMetadata,
|
|
98
106
|
metadata,
|
|
99
107
|
parseFile,
|
|
100
108
|
callbacks,
|
|
109
|
+
convertBase64toBlob,
|
|
101
110
|
TinyMediaPlayer.#unknownArtist,
|
|
102
111
|
);
|
|
103
112
|
}
|
|
@@ -1202,7 +1211,14 @@ class TinyMediaPlayer extends TinyDebugger {
|
|
|
1202
1211
|
checkDestroy(this.#destroyed);
|
|
1203
1212
|
this.log('info', `Attempting to play track at index: ${this.#currentIndex}`);
|
|
1204
1213
|
const adapter = this.#getActiveAdapter();
|
|
1205
|
-
if (!adapter)
|
|
1214
|
+
if (!adapter) {
|
|
1215
|
+
this.log(
|
|
1216
|
+
'error',
|
|
1217
|
+
'Failed to play track:',
|
|
1218
|
+
`Active adapter not found for track at index ${this.#currentIndex}.`,
|
|
1219
|
+
);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1206
1222
|
|
|
1207
1223
|
// Ensure the adapter aligns with the global volume before playing
|
|
1208
1224
|
if (this.#smoothPlayPauseVolume) {
|
|
@@ -117,6 +117,7 @@ declare class TinyMediaPlayer extends TinyDebugger {
|
|
|
117
117
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
118
118
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
119
119
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
120
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
120
121
|
* @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
|
|
121
122
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
122
123
|
*/
|
|
@@ -129,7 +130,7 @@ declare class TinyMediaPlayer extends TinyDebugger {
|
|
|
129
130
|
}, parseFile?: ParseMediaContentMetadata, callbacks?: {
|
|
130
131
|
onProgress?: (progress: LoadingMediaProgress) => void;
|
|
131
132
|
onError?: (error: MediaLoadingErrorData) => void;
|
|
132
|
-
}): Promise<MediaContent>;
|
|
133
|
+
}, convertBase64toBlob?: boolean): Promise<MediaContent>;
|
|
133
134
|
get destroyed(): boolean;
|
|
134
135
|
/** @returns {number} The duration (ms) of the volume fade speed. */
|
|
135
136
|
get fadeVolumeSpeed(): number;
|
|
@@ -76,11 +76,12 @@ class TinyMediaPlayer extends TinyDebugger {
|
|
|
76
76
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
77
77
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
78
78
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
79
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
79
80
|
* @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
|
|
80
81
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
81
82
|
*/
|
|
82
|
-
static async parseContent(source, defaultMetadata, metadata, parseFile, callbacks) {
|
|
83
|
-
return parseMediaMetadata(source, defaultMetadata, metadata, parseFile, callbacks, TinyMediaPlayer.#unknownArtist);
|
|
83
|
+
static async parseContent(source, defaultMetadata, metadata, parseFile, callbacks, convertBase64toBlob) {
|
|
84
|
+
return parseMediaMetadata(source, defaultMetadata, metadata, parseFile, callbacks, convertBase64toBlob, TinyMediaPlayer.#unknownArtist);
|
|
84
85
|
}
|
|
85
86
|
/** @type {boolean} */
|
|
86
87
|
#destroyed = false;
|
|
@@ -1073,8 +1074,10 @@ class TinyMediaPlayer extends TinyDebugger {
|
|
|
1073
1074
|
checkDestroy(this.#destroyed);
|
|
1074
1075
|
this.log('info', `Attempting to play track at index: ${this.#currentIndex}`);
|
|
1075
1076
|
const adapter = this.#getActiveAdapter();
|
|
1076
|
-
if (!adapter)
|
|
1077
|
+
if (!adapter) {
|
|
1078
|
+
this.log('error', 'Failed to play track:', `Active adapter not found for track at index ${this.#currentIndex}.`);
|
|
1077
1079
|
return;
|
|
1080
|
+
}
|
|
1078
1081
|
// Ensure the adapter aligns with the global volume before playing
|
|
1079
1082
|
if (this.#smoothPlayPauseVolume) {
|
|
1080
1083
|
await this.#fadeAdapterVolume(this.#volume);
|
|
@@ -150,16 +150,25 @@ class TinyRadioFm extends events.EventEmitter {
|
|
|
150
150
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
151
151
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
152
152
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
153
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
153
154
|
* @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
|
|
154
155
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
155
156
|
*/
|
|
156
|
-
static async parseContent(
|
|
157
|
+
static async parseContent(
|
|
158
|
+
source,
|
|
159
|
+
defaultMetadata,
|
|
160
|
+
metadata,
|
|
161
|
+
parseFile,
|
|
162
|
+
callbacks,
|
|
163
|
+
convertBase64toBlob,
|
|
164
|
+
) {
|
|
157
165
|
return mediaContent.parseMediaMetadata(
|
|
158
166
|
source,
|
|
159
167
|
defaultMetadata,
|
|
160
168
|
metadata,
|
|
161
169
|
parseFile,
|
|
162
170
|
callbacks,
|
|
171
|
+
convertBase64toBlob,
|
|
163
172
|
TinyRadioFm.#unknownArtist,
|
|
164
173
|
);
|
|
165
174
|
}
|
|
@@ -341,6 +341,7 @@ declare class TinyRadioFm extends EventEmitter {
|
|
|
341
341
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
342
342
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
343
343
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
344
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
344
345
|
* @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
|
|
345
346
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
346
347
|
*/
|
|
@@ -353,7 +354,7 @@ declare class TinyRadioFm extends EventEmitter {
|
|
|
353
354
|
}, parseFile?: ParseMediaContentMetadata, callbacks?: {
|
|
354
355
|
onProgress?: (progress: LoadingMediaProgress) => void;
|
|
355
356
|
onError?: (error: MediaLoadingErrorData) => void;
|
|
356
|
-
}): Promise<MediaContent>;
|
|
357
|
+
}, convertBase64toBlob?: boolean): Promise<MediaContent>;
|
|
357
358
|
/**
|
|
358
359
|
* Gets the current value used to represent unknown artists.
|
|
359
360
|
* @returns {UnknownArtistGetter}
|
|
@@ -128,11 +128,12 @@ class TinyRadioFm extends EventEmitter {
|
|
|
128
128
|
* @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
|
|
129
129
|
* @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
|
|
130
130
|
* @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
|
|
131
|
+
* @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method.
|
|
131
132
|
* @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
|
|
132
133
|
* @throws {MediaLoadingError} If the preparation process fails at any stage.
|
|
133
134
|
*/
|
|
134
|
-
static async parseContent(source, defaultMetadata, metadata, parseFile, callbacks) {
|
|
135
|
-
return parseMediaMetadata(source, defaultMetadata, metadata, parseFile, callbacks, TinyRadioFm.#unknownArtist);
|
|
135
|
+
static async parseContent(source, defaultMetadata, metadata, parseFile, callbacks, convertBase64toBlob) {
|
|
136
|
+
return parseMediaMetadata(source, defaultMetadata, metadata, parseFile, callbacks, convertBase64toBlob, TinyRadioFm.#unknownArtist);
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
138
139
|
* @type {UnknownArtistGetter}
|
|
@@ -77,6 +77,7 @@ Downloads an audio file and uses a provided parser to extract its internal metad
|
|
|
77
77
|
* **Parameters:**
|
|
78
78
|
* `url` (string): The full URL of the audio file.
|
|
79
79
|
* `parseFile` (Function): A callback that accepts a `Blob` and returns a promise with metadata.
|
|
80
|
+
* `convertBase64toBlob` (boolean): If true, the image content will be converted directly into a high-performance Blob URL, use this method.
|
|
80
81
|
* **Returns:** `Promise<MediaContentMetadata>`
|
|
81
82
|
* **Throws:** `TypeError` for invalid arguments or `Error` for network/parsing failures.
|
|
82
83
|
|
|
@@ -94,6 +95,7 @@ Downloads an audio file and uses a provided parser to extract its internal metad
|
|
|
94
95
|
| `metadata` | `Partial<MediaContent>` | Manual overrides for the metadata (highest priority). |
|
|
95
96
|
| `parseFile` | `ParseMediaContentMetadata` | The library function used to parse the file. |
|
|
96
97
|
| `callbacks` | `Object` | Contains `onProgress` and `onError` listeners. |
|
|
98
|
+
| `convertBase64toBlob` | `boolean` | If true, the image content will be converted directly into a high-performance Blob URL, use this method.
|
|
97
99
|
| `unknownArtist` | `UnknownArtistGetter` | Logic to determine the artist if none is found. |
|
|
98
100
|
|
|
99
101
|
#### 💡 Usage Examples
|
|
@@ -14,6 +14,7 @@ To support different media platforms, `TinyMediaPlayer` relies on **Adapters**.
|
|
|
14
14
|
#### Methods
|
|
15
15
|
| Method | Description | Parameters | Returns |
|
|
16
16
|
| :--- | :--- | :--- | :--- |
|
|
17
|
+
| `static getThumbnailUrl` | Returns the thumbnail URL for the provided track ID. Throws `TypeError` if `trackId` is invalid. | `trackId: string` | `string` |
|
|
17
18
|
| `static canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
|
|
18
19
|
| `canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
|
|
19
20
|
| `isReady` | Synchronously checks if the adapter is ready. | None | `boolean` |
|
|
@@ -180,7 +181,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
180
181
|
* **Getter/Setter**: Allows customization of the default event subscription list.
|
|
181
182
|
|
|
182
183
|
#### Methods
|
|
183
|
-
* **`parseContent(source, defaultMetadata, metadata, parseFile, callbacks)`**:
|
|
184
|
+
* **`parseContent(source, defaultMetadata, metadata, parseFile, callbacks, convertBase64toBlob)`**:
|
|
184
185
|
* A static factory method to prepare a `MediaContent` object by extracting metadata from a URL or HTMLMediaElement.
|
|
185
186
|
* **Parameters**:
|
|
186
187
|
* `source`: `string | HTMLMediaElement`
|
|
@@ -188,6 +189,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
188
189
|
* `metadata`: `Partial<MediaContentBase & MediaContentMetadata>`
|
|
189
190
|
* `parseFile`: `ParseMediaContentMetadata`
|
|
190
191
|
* `callbacks`: `Object` (containing `onProgress` and `onError`)
|
|
192
|
+
* `convertBase64toBlob`: `boolean`
|
|
191
193
|
* **Returns**: `Promise<MediaContent>`.
|
|
192
194
|
|
|
193
195
|
---
|
|
@@ -231,7 +233,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
231
233
|
* **`registerAdapter(adapter)`**: Registers a new provider.
|
|
232
234
|
* `adapter`: An instance of a class extending `BaseMediaAdapter`.
|
|
233
235
|
* **`removeAdapter(adapter)`**: Removes a specific registered adapter.
|
|
234
|
-
* **`destroyAdapter(adapter)`**: Destroys and removes a specific registered adapter.
|
|
236
|
+
* **`destroyAdapter(adapter)`**: Destroys and removes a specific registered media adapter.
|
|
235
237
|
* **`hasAdapter(adapter)`**: Checks if a specific adapter is registered.
|
|
236
238
|
* **`clearAdapters()`**: Clears the list of adapters (does not call `destroy` on them).
|
|
237
239
|
* **`destroyAllAdapters()`**: Destroys and removes all registered media adapters.
|
|
@@ -254,7 +256,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
|
|
|
254
256
|
* **`removeTrack(index)`**: **(Async)** Removes a track and adjusts the current index/playback accordingly.
|
|
255
257
|
* **`searchTrack(query)`**: Searches the playlist (string or function).
|
|
256
258
|
* `query`: A `string` (searches title, artist, or album) or a `function` (custom logic).
|
|
257
|
-
*
|
|
259
|
+
* `Returns`: `SearchResult[]` (array of objects containing the track and their corresponding indices).
|
|
258
260
|
* **`clearPlaylist()`**: **(Async)** Stops playback and empties the entire playlist.
|
|
259
261
|
|
|
260
262
|
#### ⏯️ Playback Controls
|
|
@@ -42,7 +42,7 @@ The behavior of the engine is controlled via the `RadioConfig` object.
|
|
|
42
42
|
|
|
43
43
|
### 🏗️ Static Methods
|
|
44
44
|
|
|
45
|
-
#### `static parseContent(source, defaultMetadata, metadata, parseFile, callbacks)`
|
|
45
|
+
#### `static parseContent(source, defaultMetadata, metadata, parseFile, callbacks, convertBase64toBlob)`
|
|
46
46
|
Prepares a `MediaContent` object by extracting metadata from an audio source.
|
|
47
47
|
* **Parameters:**
|
|
48
48
|
* `source`: A URL string or an existing `HTMLMediaElement`.
|
|
@@ -50,6 +50,7 @@ Prepares a `MediaContent` object by extracting metadata from an audio source.
|
|
|
50
50
|
* `metadata`: Optional manual overrides.
|
|
51
51
|
* `parseFile`: Internal helper for file parsing.
|
|
52
52
|
* `callbacks`: Object containing `onProgress` and `onError` handlers.
|
|
53
|
+
* `convertBase64toBlob`: If true, the image content will be converted directly into a high-performance Blob URL, use this method.
|
|
53
54
|
* **Returns:** `Promise<MediaContent>`
|
|
54
55
|
* **Throws:** `MediaLoadingError`
|
|
55
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.11",
|
|
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"
|