tiny-essentials 1.28.4 → 1.28.5
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/5.md +31 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.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/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 +268 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +118 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +237 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +265 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +118 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +234 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +671 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +259 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +597 -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 +165 -0
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +102 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +144 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +589 -103
- package/dist/v1/libs/TinyMediaPlayer.d.mts +150 -65
- package/dist/v1/libs/TinyMediaPlayer.mjs +535 -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 +239 -32
- package/docs/v1/libs/TinyTimeout.md +1 -14
- package/package.json +21 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export type PictureDataType = import('../../basics/mediaContent.mjs').PictureDataType;
|
|
3
|
+
export type MediaContent = import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>;
|
|
4
|
+
export type ContentTimeData = {
|
|
5
|
+
/**
|
|
6
|
+
* - The total duration of the media in milliseconds.
|
|
7
|
+
*/
|
|
8
|
+
total: number;
|
|
9
|
+
/**
|
|
10
|
+
* - The current playback position in milliseconds.
|
|
11
|
+
*/
|
|
12
|
+
current: number;
|
|
13
|
+
/**
|
|
14
|
+
* - The remaining time until the media ends in milliseconds.
|
|
15
|
+
*/
|
|
16
|
+
remaining: number;
|
|
17
|
+
/**
|
|
18
|
+
* - The percentage of the media that has been played (0 to 100).
|
|
19
|
+
*/
|
|
20
|
+
playbackPercentage: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Interface definition for a Media Provider Adapter.
|
|
24
|
+
* All specific API wrappers must extend and implement this class.
|
|
25
|
+
* @abstract
|
|
26
|
+
*/
|
|
27
|
+
declare class BaseMediaAdapter extends EventEmitter {
|
|
28
|
+
#private;
|
|
29
|
+
constructor();
|
|
30
|
+
get destroyed(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Determines if this adapter can play the provided content.
|
|
33
|
+
* @param {MediaContent} content - The media content to evaluate.
|
|
34
|
+
* @returns {boolean} True if the adapter can handle the content, false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
canHandle(content: MediaContent): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Starts or resumes playback of the provided content.
|
|
39
|
+
* @param {MediaContent} content - The media content to play.
|
|
40
|
+
* @returns {Promise<void>}
|
|
41
|
+
*/
|
|
42
|
+
play(content: MediaContent): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Pauses the current playback.
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
pause(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Stops the playback completely and resets the internal platform state.
|
|
50
|
+
* @returns {Promise<void>}
|
|
51
|
+
*/
|
|
52
|
+
stop(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Seeks to a specific time in the media timeline.
|
|
55
|
+
* @param {number} timeMs - The target time in milliseconds.
|
|
56
|
+
* @returns {Promise<void>}
|
|
57
|
+
*/
|
|
58
|
+
seek(timeMs: number): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves the current playback time from the underlying API.
|
|
61
|
+
* @returns {number} The current time in milliseconds.
|
|
62
|
+
*/
|
|
63
|
+
getCurrentTime(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the total duration of the content.
|
|
66
|
+
* @returns {number} The total duration in milliseconds.
|
|
67
|
+
*/
|
|
68
|
+
getTotalDuration(): number;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the remaining time until the content ends.
|
|
71
|
+
* @returns {number} The remaining time in milliseconds.
|
|
72
|
+
*/
|
|
73
|
+
getRemainingTime(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the percentage of the content that has been played.
|
|
76
|
+
* @returns {number} The percentage from 0 to 100.
|
|
77
|
+
*/
|
|
78
|
+
getPlaybackPercentage(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
81
|
+
* @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
|
|
82
|
+
*/
|
|
83
|
+
getTimeData(): ContentTimeData;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the playback volume for the underlying API.
|
|
86
|
+
* @param {number} volume - The volume level from 0.0 to 1.0.
|
|
87
|
+
* @returns {void}
|
|
88
|
+
*/
|
|
89
|
+
setVolume(volume: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Gets the playback volume for the underlying API.
|
|
92
|
+
* @returns {number} - The volume level from 0.0 to 1.0.
|
|
93
|
+
*/
|
|
94
|
+
getVolume(): number;
|
|
95
|
+
/**
|
|
96
|
+
* Cleans up the instance.
|
|
97
|
+
* @returns {void}
|
|
98
|
+
*/
|
|
99
|
+
destroy(): void;
|
|
100
|
+
}
|
|
101
|
+
export { BaseMediaAdapter };
|
|
102
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { createCheckDestroyed } from '../utils.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
5
|
+
* @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} ContentTimeData
|
|
9
|
+
* @property {number} total - The total duration of the media in milliseconds.
|
|
10
|
+
* @property {number} current - The current playback position in milliseconds.
|
|
11
|
+
* @property {number} remaining - The remaining time until the media ends in milliseconds.
|
|
12
|
+
* @property {number} playbackPercentage - The percentage of the media that has been played (0 to 100).
|
|
13
|
+
*/
|
|
14
|
+
const checkDestroy = createCheckDestroyed('BaseMediaAdapter');
|
|
15
|
+
/**
|
|
16
|
+
* Interface definition for a Media Provider Adapter.
|
|
17
|
+
* All specific API wrappers must extend and implement this class.
|
|
18
|
+
* @abstract
|
|
19
|
+
*/
|
|
20
|
+
class BaseMediaAdapter extends EventEmitter {
|
|
21
|
+
constructor() {
|
|
22
|
+
if (new.target === BaseMediaAdapter) {
|
|
23
|
+
throw new Error('BaseMediaAdapter is an abstract class and cannot be instantiated directly.');
|
|
24
|
+
}
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
/** @type {boolean} */
|
|
28
|
+
#destroyed = false;
|
|
29
|
+
get destroyed() {
|
|
30
|
+
return this.#destroyed;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Determines if this adapter can play the provided content.
|
|
34
|
+
* @param {MediaContent} content - The media content to evaluate.
|
|
35
|
+
* @returns {boolean} True if the adapter can handle the content, false otherwise.
|
|
36
|
+
*/
|
|
37
|
+
canHandle(content) {
|
|
38
|
+
checkDestroy(this.#destroyed);
|
|
39
|
+
throw new Error('Method "canHandle" must be implemented by the subclass.');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Starts or resumes playback of the provided content.
|
|
43
|
+
* @param {MediaContent} content - The media content to play.
|
|
44
|
+
* @returns {Promise<void>}
|
|
45
|
+
*/
|
|
46
|
+
async play(content) {
|
|
47
|
+
checkDestroy(this.#destroyed);
|
|
48
|
+
throw new Error('Method "play" must be implemented by the subclass.');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pauses the current playback.
|
|
52
|
+
* @returns {Promise<void>}
|
|
53
|
+
*/
|
|
54
|
+
async pause() {
|
|
55
|
+
checkDestroy(this.#destroyed);
|
|
56
|
+
throw new Error('Method "pause" must be implemented by the subclass.');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Stops the playback completely and resets the internal platform state.
|
|
60
|
+
* @returns {Promise<void>}
|
|
61
|
+
*/
|
|
62
|
+
async stop() {
|
|
63
|
+
checkDestroy(this.#destroyed);
|
|
64
|
+
throw new Error('Method "stop" must be implemented by the subclass.');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Seeks to a specific time in the media timeline.
|
|
68
|
+
* @param {number} timeMs - The target time in milliseconds.
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
71
|
+
async seek(timeMs) {
|
|
72
|
+
checkDestroy(this.#destroyed);
|
|
73
|
+
throw new Error('Method "seek" must be implemented by the subclass.');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the current playback time from the underlying API.
|
|
77
|
+
* @returns {number} The current time in milliseconds.
|
|
78
|
+
*/
|
|
79
|
+
getCurrentTime() {
|
|
80
|
+
checkDestroy(this.#destroyed);
|
|
81
|
+
throw new Error('Method "getCurrentTime" must be implemented by the subclass.');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the total duration of the content.
|
|
85
|
+
* @returns {number} The total duration in milliseconds.
|
|
86
|
+
*/
|
|
87
|
+
getTotalDuration() {
|
|
88
|
+
checkDestroy(this.#destroyed);
|
|
89
|
+
throw new Error('Method "getTotalDuration" must be implemented by the subclass.');
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Gets the remaining time until the content ends.
|
|
93
|
+
* @returns {number} The remaining time in milliseconds.
|
|
94
|
+
*/
|
|
95
|
+
getRemainingTime() {
|
|
96
|
+
checkDestroy(this.#destroyed);
|
|
97
|
+
throw new Error('Method "getRemainingTime" must be implemented by the subclass.');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the percentage of the content that has been played.
|
|
101
|
+
* @returns {number} The percentage from 0 to 100.
|
|
102
|
+
*/
|
|
103
|
+
getPlaybackPercentage() {
|
|
104
|
+
checkDestroy(this.#destroyed);
|
|
105
|
+
throw new Error('Method "getPlaybackPercentage" must be implemented by the subclass.');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves a consolidated object containing all time-related metrics for the current media content.
|
|
109
|
+
* @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
|
|
110
|
+
*/
|
|
111
|
+
getTimeData() {
|
|
112
|
+
checkDestroy(this.#destroyed);
|
|
113
|
+
throw new Error('Method "getTimeData" must be implemented by the subclass.');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sets the playback volume for the underlying API.
|
|
117
|
+
* @param {number} volume - The volume level from 0.0 to 1.0.
|
|
118
|
+
* @returns {void}
|
|
119
|
+
*/
|
|
120
|
+
setVolume(volume) {
|
|
121
|
+
checkDestroy(this.#destroyed);
|
|
122
|
+
throw new Error('Method "setVolume" must be implemented by the subclass.');
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets the playback volume for the underlying API.
|
|
126
|
+
* @returns {number} - The volume level from 0.0 to 1.0.
|
|
127
|
+
*/
|
|
128
|
+
getVolume() {
|
|
129
|
+
checkDestroy(this.#destroyed);
|
|
130
|
+
throw new Error('Method "getVolume" must be implemented by the subclass.');
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Cleans up the instance.
|
|
134
|
+
* @returns {void}
|
|
135
|
+
*/
|
|
136
|
+
destroy() {
|
|
137
|
+
if (this.#destroyed)
|
|
138
|
+
return;
|
|
139
|
+
this.removeAllListeners();
|
|
140
|
+
this.#destroyed = true;
|
|
141
|
+
this.emit('destroyed');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export { BaseMediaAdapter };
|