multi_embed_player 3.0.1 → 3.1.0

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.
Files changed (128) hide show
  1. package/.github/workflows/build-and-deploy.yml +44 -0
  2. package/.gitmodules +3 -0
  3. package/CLAUDE.md +92 -0
  4. package/README.md +0 -24
  5. package/add_types.sh +61 -0
  6. package/browserExtention/chrome/background.js +55 -0
  7. package/browserExtention/chrome/extention.json +1 -0
  8. package/browserExtention/chrome/liteplayer.js +26439 -0
  9. package/browserExtention/chrome/manifest.json +31 -0
  10. package/browserExtention/chrome/player-selector.js +1854 -0
  11. package/browserExtention/firefox/background.js +27 -0
  12. package/browserExtention/firefox/extention.json +1 -0
  13. package/browserExtention/firefox/liteplayer.js +26439 -0
  14. package/browserExtention/firefox/manifest.json +19 -0
  15. package/browserExtention/firefox/player-selector.js +1854 -0
  16. package/documents/.hugo_build.lock +0 -0
  17. package/documents/archetypes/default.md +5 -0
  18. package/documents/assets/jsconfig.json +11 -0
  19. package/documents/content/docs/install.md +103 -0
  20. package/documents/content/docs/quickstart.md +51 -0
  21. package/documents/content/docs/reference/HTML.md +31 -0
  22. package/documents/content/docs/reference/_index.md +10 -0
  23. package/documents/content/docs/reference/error_code.md +23 -0
  24. package/documents/content/docs/reference/iframe_api.md +737 -0
  25. package/documents/content/docs/reference/iframe_class.md +230 -0
  26. package/documents/content/docs/reference/multi_embed_player_class.md +113 -0
  27. package/documents/content/docs/reference/reserved_words.md +71 -0
  28. package/documents/content/docs/usage/GDPR_mode.md +77 -0
  29. package/documents/content/docs/usage/_index.md +10 -0
  30. package/documents/content/docs/usage/custom_playlist.md +239 -0
  31. package/documents/content/docs/usage/embed_api.md +163 -0
  32. package/documents/content/docs/usage/embed_various_service.md +81 -0
  33. package/documents/content/docs/usage/thumbnail_click.md +57 -0
  34. package/documents/go.mod +8 -0
  35. package/documents/go.sum +14 -0
  36. package/documents/hugo.toml +18 -0
  37. package/documents/layouts/partials/docs/sidebar.html +117 -0
  38. package/documents/layouts/partials/landing/features.html +47 -0
  39. package/documents/layouts/robots.txt +4 -0
  40. package/documents/static/_headers +7 -0
  41. package/documents/static/localStorageCheck.html +27 -0
  42. package/documents/static/no_extention.json +1 -0
  43. package/example.html +27 -0
  44. package/extention.json +1 -0
  45. package/icon/video_not_found.odg +0 -0
  46. package/icon/video_not_found.svgz +0 -0
  47. package/iframe_api/bilibili.ts +1095 -0
  48. package/iframe_api/niconico.ts +429 -0
  49. package/iframe_api/soundcloud.ts +450 -0
  50. package/iframe_api/youtube.ts +311 -0
  51. package/multi_embed_player.ts +989 -0
  52. package/package.json +10 -41
  53. package/player_api_gate/bilibili-api-gate/cgi/cpp/bilibili-api-gate-cgi.cpp +281 -0
  54. package/player_api_gate/bilibili-api-gate/cgi/go/src.go +46 -0
  55. package/player_api_gate/bilibili-api-gate/cloudflare_workers/package-lock.json +1356 -0
  56. package/player_api_gate/bilibili-api-gate/cloudflare_workers/package.json +12 -0
  57. package/player_api_gate/bilibili-api-gate/cloudflare_workers/src/index.js +50 -0
  58. package/player_api_gate/bilibili-api-gate/cloudflare_workers/wrangler.toml +3 -0
  59. package/player_api_gate/iframe-api-ts/.editorconfig +12 -0
  60. package/player_api_gate/iframe-api-ts/.prettierrc +6 -0
  61. package/player_api_gate/iframe-api-ts/package-lock.json +3054 -0
  62. package/player_api_gate/iframe-api-ts/package.json +18 -0
  63. package/player_api_gate/iframe-api-ts/src/bilibili.ts +49 -0
  64. package/player_api_gate/iframe-api-ts/src/index.ts +35 -0
  65. package/player_api_gate/iframe-api-ts/src/niconico.ts +95 -0
  66. package/player_api_gate/iframe-api-ts/src/soundcloud.ts +38 -0
  67. package/player_api_gate/iframe-api-ts/src/types.ts +115 -0
  68. package/player_api_gate/iframe-api-ts/src/url-proxy.ts +29 -0
  69. package/player_api_gate/iframe-api-ts/src/utils.ts +82 -0
  70. package/player_api_gate/iframe-api-ts/src/youtube.ts +41 -0
  71. package/player_api_gate/iframe-api-ts/test/bilibili.spec.ts +47 -0
  72. package/player_api_gate/iframe-api-ts/test/env.d.ts +3 -0
  73. package/player_api_gate/iframe-api-ts/test/index.spec.ts +59 -0
  74. package/player_api_gate/iframe-api-ts/test/niconico.spec.ts +55 -0
  75. package/player_api_gate/iframe-api-ts/test/soundcloud.spec.ts +55 -0
  76. package/player_api_gate/iframe-api-ts/test/tsconfig.json +8 -0
  77. package/player_api_gate/iframe-api-ts/test/url-proxy.spec.ts +46 -0
  78. package/player_api_gate/iframe-api-ts/test/youtube.spec.ts +45 -0
  79. package/player_api_gate/iframe-api-ts/tsconfig.json +45 -0
  80. package/player_api_gate/iframe-api-ts/vitest.config.mts +11 -0
  81. package/player_api_gate/iframe-api-ts/worker-configuration.d.ts +5768 -0
  82. package/player_api_gate/iframe-api-ts/wrangler.jsonc +47 -0
  83. package/player_api_gate/iframe_api/.editorconfig +13 -0
  84. package/player_api_gate/iframe_api/.prettierrc +6 -0
  85. package/player_api_gate/iframe_api/package-lock.json +1307 -0
  86. package/player_api_gate/iframe_api/package.json +12 -0
  87. package/player_api_gate/iframe_api/src/bilibili_api.js +60 -0
  88. package/player_api_gate/iframe_api/src/index.js +47 -0
  89. package/player_api_gate/iframe_api/src/niconico_api.js +112 -0
  90. package/player_api_gate/iframe_api/src/soundcloud_api.js +57 -0
  91. package/player_api_gate/iframe_api/src/url_proxy.js +28 -0
  92. package/player_api_gate/iframe_api/src/youtube_api.js +44 -0
  93. package/player_api_gate/iframe_api/wrangler.toml +51 -0
  94. package/player_api_gate/niconico-imager/cgi/go/src.go +74 -0
  95. package/player_api_gate/niconico-imager/cloudflare_workers/package-lock.json +2175 -0
  96. package/player_api_gate/niconico-imager/cloudflare_workers/package.json +12 -0
  97. package/player_api_gate/niconico-imager/cloudflare_workers/src/index.js +78 -0
  98. package/player_api_gate/niconico-imager/cloudflare_workers/wrangler.toml +3 -0
  99. package/test_script.html +172 -0
  100. package/tsconfig.json +36 -0
  101. package/dist/iframe_api/bilibili.d.ts +0 -91
  102. package/dist/iframe_api/bilibili.d.ts.map +0 -1
  103. package/dist/iframe_api/bilibili.js +0 -451
  104. package/dist/iframe_api/bilibili.js.map +0 -1
  105. package/dist/iframe_api/index.d.ts +0 -6
  106. package/dist/iframe_api/index.d.ts.map +0 -1
  107. package/dist/iframe_api/index.js +0 -8
  108. package/dist/iframe_api/index.js.map +0 -1
  109. package/dist/iframe_api/niconico.d.ts +0 -42
  110. package/dist/iframe_api/niconico.d.ts.map +0 -1
  111. package/dist/iframe_api/niconico.js +0 -181
  112. package/dist/iframe_api/niconico.js.map +0 -1
  113. package/dist/iframe_api/soundcloud.d.ts +0 -80
  114. package/dist/iframe_api/soundcloud.d.ts.map +0 -1
  115. package/dist/iframe_api/soundcloud.js +0 -188
  116. package/dist/iframe_api/soundcloud.js.map +0 -1
  117. package/dist/iframe_api/youtube.d.ts +0 -133
  118. package/dist/iframe_api/youtube.d.ts.map +0 -1
  119. package/dist/iframe_api/youtube.js +0 -278
  120. package/dist/iframe_api/youtube.js.map +0 -1
  121. package/dist/multi_embed_player.d.ts +0 -48
  122. package/dist/multi_embed_player.d.ts.map +0 -1
  123. package/dist/multi_embed_player.js +0 -318
  124. package/dist/multi_embed_player.js.map +0 -1
  125. package/dist/types.d.ts +0 -126
  126. package/dist/types.d.ts.map +0 -1
  127. package/dist/types.js +0 -22
  128. package/dist/types.js.map +0 -1
@@ -0,0 +1,450 @@
1
+ declare var SC: any;
2
+
3
+ //Notice! This file JSDOC is generated by gitHub Copilot
4
+ // So some of the comments may be wrong
5
+ // Please refer to documents https://multi-embed-player.pages.dev/docs/reference/iframe_class/#mep_soundcloud
6
+
7
+ /**
8
+ * @typedef {Object} mep_soundcloud_load_object
9
+ * @property {string} videoId - The ID of the video.
10
+ * @property {number} [startSeconds] - The start time of the video.
11
+ * @property {number} [endSeconds] - The end time of the video.
12
+ */
13
+
14
+ /**
15
+ * @typedef {Object} mep_soundcloud_playerVars
16
+ * @property {number} [autoplay] - Whether to autoplay the initial video.
17
+ * @property {number} [hide_related] - Hide related videos after the video ends.
18
+ * @property {number} [show_comments] - Show comments.
19
+ * @property {number} [show_user] - Show the user's name and profile picture.
20
+ * @property {number} [show_reposts] - Show reposts.
21
+ * @property {number} [visual] - Show the video title and other visual metadata.
22
+ * @property {number} [startSeconds] - The start time of the video.
23
+ * @property {number} [endSeconds] - The end time of the video.
24
+ */
25
+
26
+ /**
27
+ * @typedef {Object} mep_soundcloud_content
28
+ * @property {string} videoId - The ID of the video.
29
+ * @property {mep_soundcloud_playerVars} [playerVars] - Player parameters.
30
+ * @property {number} width - The width of the video player.
31
+ * @property {number} height - The height of the video player.
32
+ */
33
+
34
+ // TypeScript interfaces based on JSDoc
35
+ interface mep_soundcloud_load_object {
36
+ videoId: string;
37
+ startSeconds?: number;
38
+ endSeconds?: number;
39
+ }
40
+
41
+ interface mep_soundcloud_playerVars {
42
+ autoplay?: number | string;
43
+ hide_related?: number | string;
44
+ show_comments?: number | string;
45
+ show_user?: number | string;
46
+ show_reposts?: number | string;
47
+ visual?: number | string;
48
+ startSeconds?: number;
49
+ endSeconds?: number;
50
+ [key: string]: number | string | undefined;
51
+ }
52
+
53
+ interface mep_soundcloud_content {
54
+ videoId: string;
55
+ playerVars?: mep_soundcloud_playerVars;
56
+ width: number;
57
+ height: number;
58
+ }
59
+
60
+ interface TrackData {
61
+ currentPosition: number;
62
+ }
63
+
64
+ interface SoundMetadata {
65
+ title: string;
66
+ duration: number;
67
+ }
68
+
69
+ /**
70
+ * Class representing a SoundCloud player.
71
+ */
72
+ class mep_soundcloud{
73
+ player: HTMLIFrameElement = document.createElement("iframe");
74
+ playerVars: mep_soundcloud_playerVars | undefined;
75
+ player_statusdata: any;
76
+ autoplay: boolean = false;
77
+ player_widget: any;
78
+ player_metadata: any;
79
+ before_mute_volume: number = 100;
80
+ forse_pause: boolean = false;
81
+ first_seek_time: number = -1;
82
+ endSeconds: number = -1;
83
+ pause_sended: boolean = false;
84
+ interval: number = 0;
85
+ previous_player_status: number = -1;
86
+ retry_count: number = 0;
87
+
88
+ static soundcloud_api_loaded: boolean | null = null;
89
+ static soundcloud_api_promise: (() => void)[] = [];
90
+ static numericRegex = /^[0-9]+$/;
91
+ async #load_soundcloud_api(){
92
+ if((window as any).mep_soundcloud.soundcloud_api_loaded === null){
93
+ if(typeof SC!=="object"){
94
+ (window as any).mep_soundcloud.soundcloud_api_loaded = false;
95
+ const script_document = document.createElement("script");
96
+ script_document.src = "https://w.soundcloud.com/player/api.js";
97
+ script_document.addEventListener("load",()=>{(window as any).mep_soundcloud.soundcloud_api_loaded = true;(window as any).mep_soundcloud.soundcloud_api_promise.forEach((func: () => void)=>func())});
98
+ script_document.addEventListener("error",()=>{this.player.dispatchEvent(new CustomEvent("onError",{detail:{code:1001}}))});
99
+ document.body.appendChild(script_document);
100
+ await new Promise((resolve,reject)=>(window as any).mep_soundcloud.soundcloud_api_promise.push(resolve));
101
+ }
102
+ else{
103
+ (window as any).mep_soundcloud.soundcloud_api_loaded = true;
104
+ }
105
+ }
106
+ else if((window as any).mep_soundcloud.soundcloud_api_loaded === false){
107
+ await new Promise((resolve,reject)=>(window as any).mep_soundcloud.soundcloud_api_promise.push(resolve));
108
+ }
109
+ }
110
+ constructor(replacing_element: string | HTMLElement, content: mep_soundcloud_content, player_set_event_function?: (player: HTMLIFrameElement) => void){
111
+ this.#load(replacing_element,content,player_set_event_function);
112
+ }
113
+ async #load(replacing_element: string | HTMLElement, content: mep_soundcloud_content, player_set_event_function?: (player: HTMLIFrameElement) => void){
114
+ this.player.style.border = "none";
115
+ this.player.allow = "autoplay";
116
+ if(typeof player_set_event_function === "function"){
117
+ player_set_event_function(this.player);
118
+ }
119
+ await this.#load_soundcloud_api();
120
+ let iframe_replace_node: HTMLElement | null = null;
121
+ if(typeof replacing_element==="string"){
122
+ iframe_replace_node = document.getElementById(replacing_element);
123
+ } else {
124
+ iframe_replace_node = replacing_element;
125
+ }
126
+ let url_params = new URLSearchParams();
127
+ let tflist = ["autoplay","hide_related","show_comments","show_user","show_user","show_reposts","visual"];
128
+ this.playerVars = content.playerVars;
129
+ this.player_statusdata = {playing_status:1,currentPosition:0,volume:100};
130
+ if(typeof content.playerVars === "object" && content.playerVars !== null){
131
+ tflist.forEach(option=>{
132
+ if(content.playerVars && typeof content.playerVars[option]==="number"){
133
+ content.playerVars[option] = content.playerVars[option].toString()
134
+ }
135
+ if(!content.playerVars || typeof content.playerVars[option] === "undefined"){
136
+ url_params.set(option,"true");
137
+ }
138
+ else if(content.playerVars[option] === "1" || content.playerVars[option] === "true"){
139
+ url_params.set(option,"true");
140
+ }
141
+ else if(content.playerVars[option] === "0" || content.playerVars[option] === "false"){
142
+ url_params.set(option,"false");
143
+ }
144
+ else{
145
+ url_params.set(option,content.playerVars[option] as string);
146
+ }
147
+ });
148
+ if(content.playerVars && (content.playerVars.autoplay == "true" || content.playerVars.autoplay == 1)){
149
+ this.autoplay = true;
150
+ }
151
+ }
152
+ else{
153
+ tflist.forEach(option=>{url_params.set(option,"false");});
154
+ }
155
+ if((window as any).mep_soundcloud.numericRegex.test(content.videoId)){
156
+ this.player.src = `https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/${content.videoId}&${url_params.toString()}`;
157
+ }
158
+ else{
159
+ this.player.src = `https://w.soundcloud.com/player/?url=https://soundcloud.com/${content.videoId}&${url_params.toString()}`;
160
+ }
161
+ if (iframe_replace_node) {
162
+ iframe_replace_node.replaceWith(this.player);
163
+ }
164
+ this.player_widget = SC.Widget(this.player);
165
+ this.player_metadata = {};//renew when load new ones
166
+ this.forse_pause = !this.autoplay;
167
+ this.player_widget.bind(SC.Widget.Events.READY,()=>{this.#ready_function()});
168
+ this.player_widget.bind(SC.Widget.Events.PLAY_PROGRESS,(data: TrackData)=>{this.#tracker(data);this.#tracking_function()});
169
+ this.player_widget.bind(SC.Widget.Events.PLAY,()=>{if(this.first_seek_time!==-1){this.seekTo(this.first_seek_time);this.first_seek_time=-1};this.player_statusdata.playing_status = 2});
170
+ this.player_widget.bind(SC.Widget.Events.PAUSE,()=>{this.player_statusdata.playing_status = 3;this.pause_sended = false;this.forse_pause = true});
171
+ //this.player_widget.bind(SC.Widget.Events.SEEK,()=>this.player_statusdata.playing_status = 3);
172
+ this.player_widget.bind(SC.Widget.Events.FINISH,()=>{this.player.dispatchEvent(new Event("onEndVideo"));this.player_statusdata.playing_status = 4});
173
+ this.player_widget.bind(SC.Widget.Events.ERROR,()=>this.player.dispatchEvent(new Event("onError")));
174
+ if(this.autoplay){
175
+ this.#startTracking();
176
+ }
177
+ this.first_seek_time = (content.playerVars && typeof content.playerVars.startSeconds === "number")?content.playerVars.startSeconds:-1;
178
+ this.endSeconds = (content.playerVars && typeof content.playerVars.endSeconds === "number")?content.playerVars.endSeconds:-1;
179
+ }
180
+ /**
181
+ * execute when player is ready
182
+ * @param {boolean} retry
183
+ */
184
+ #ready_function(retry: boolean = false){
185
+ this.player.dispatchEvent(new Event("onReady"));
186
+ this.player_widget.getCurrentSound((data: SoundMetadata | null)=>{if(data===null){this.player.dispatchEvent(new Event("onError"))};this.player_metadata = data});
187
+ if(this.autoplay&&!this.forse_pause){
188
+ this.playVideo();
189
+ if(retry&&this.retry_count<7){
190
+ this.retry_count++;
191
+ setTimeout(()=>{this.#ready_function(true)},1000);
192
+ }
193
+ }
194
+ }
195
+ /**
196
+ * save current position
197
+ * @param {Object} trackData
198
+ */
199
+ #tracker(trackData: TrackData){
200
+ this.player_statusdata.currentPosition = trackData.currentPosition;
201
+ }
202
+ /**
203
+ * This function tracks the player's state and fires events as needed.
204
+ * Specifically, it fires events when the playback state changes or when a certain playback time is reached.
205
+ */
206
+ #tracking_function(){
207
+ //this.player_widget.getVolume((volume)=>{this.player_statusdata.volume = volume});
208
+ //this.player_widget.isPaused((pause_status)=>{pause_status?this.player_statusdata.playing_status = 3:this.player_statusdata.playing_status = 2});
209
+ if(this.previous_player_status!==this.player_statusdata.playing_status){
210
+ this.previous_player_status = this.player_statusdata.playing_status;
211
+ this.player.dispatchEvent(new CustomEvent("onStateChange",{detail:this.getPlayerState()}));
212
+ }
213
+ if(this.endSeconds!=-1&&this.endSeconds<=this.getCurrentTime()){
214
+ if(!this.pause_sended){
215
+ this.pause_sended = true;
216
+ this.pauseVideo();
217
+ this.player.dispatchEvent(new Event("onEndVideo"));
218
+ this.player_statusdata.playing_status = 4;
219
+ }
220
+ }
221
+ }
222
+ /**
223
+ * This function sets an interval for state tracking. However, in the current code, it's commented out and does nothing.
224
+ */
225
+ #startTracking(){
226
+ if(this.interval===0){
227
+ //this.interval = setInterval(()=>{this.tracking_function()},1000);
228
+ }
229
+ }
230
+ /**
231
+ * This function clears the interval set for state tracking and calls the #tracking_function() method.
232
+ */
233
+ #stopTracking(){
234
+ clearInterval(this.interval);
235
+ this.interval = 0;
236
+ this.#tracking_function();
237
+ }
238
+ /**
239
+ * This function plays the video.
240
+ */
241
+ playVideo(){
242
+ this.#startTracking();
243
+ if(this.first_seek_time!==-1){
244
+ this.seekTo(this.first_seek_time);
245
+ this.first_seek_time = -1;
246
+ }
247
+ this.player_widget.play();
248
+ }
249
+ /**
250
+ * This function pauses the video.
251
+ */
252
+ pauseVideo(){
253
+ this.#stopTracking();
254
+ this.player_widget.pause();
255
+ this.forse_pause = true;
256
+ }
257
+ /**
258
+ * This function return the current time of the video.
259
+ * @returns {number} current time of the video
260
+ */
261
+ getCurrentTime(){
262
+ return this.player_statusdata.currentPosition/1000;
263
+ }
264
+ /**
265
+ * This function return the duration of the video.
266
+ * @returns {number} duration of the video
267
+ */
268
+ getDuration(){
269
+ return this.player_metadata.duration / 1000;
270
+ }
271
+ /**
272
+ * This function seeks to a specified time in the video.
273
+ * @param {number} skipSecounds - The time to which the player should advance.
274
+ */
275
+ seekTo(skipSecounds: number){
276
+ if(typeof skipSecounds === "number"){
277
+ this.player_widget.seekTo(skipSecounds*1000);
278
+ }
279
+ else{
280
+ console.error("seekTo argument must be number");
281
+ }
282
+ }
283
+ /**
284
+ * This function sets the volume of the video player.
285
+ * @param {number} volume
286
+ */
287
+ setVolume(volume: number){
288
+ this.player_widget.setVolume(volume);
289
+ this.player_statusdata.volume = volume;
290
+ }
291
+ /**
292
+ * This function mutes the video player.
293
+ */
294
+ mute(){
295
+ this.before_mute_volume = this.player_statusdata.volume;
296
+ this.setVolume(0);
297
+ }
298
+ /**
299
+ * This function unmutes the video player.
300
+ */
301
+ unMute(){
302
+ this.setVolume(this.before_mute_volume);
303
+ }
304
+ /**
305
+ * This function checks whether the video player is muted.
306
+ * @returns {boolean} true if the video player is muted, and false if not.
307
+ */
308
+ isMuted(){
309
+ return this.player_statusdata.volume===0;
310
+ }
311
+ /**
312
+ * This function returns the volume of the video player.
313
+ * @returns {number} volume of the video player
314
+ */
315
+ getVolume(){
316
+ return this.player_statusdata.volume;
317
+ }
318
+ /**
319
+ * This function returns the status of the video player.
320
+ * @returns {number} status code
321
+ */
322
+ getPlayerState(){
323
+ return this.player_statusdata.playing_status;
324
+ }
325
+ /**
326
+ * This function returns the title of the video.
327
+ * @returns {string} title of the video
328
+ */
329
+ getTitle(){
330
+ return this.player_metadata.title;
331
+ }
332
+ /**
333
+ * return duration between start and end seconds
334
+ * @returns {number} dulation of between start and end
335
+ */
336
+ getRealDulation(){//original function
337
+ if(this.endSeconds==-1){
338
+ return this.getDuration() - this.first_seek_time;
339
+ }
340
+ else{
341
+ return this.endSeconds - this.first_seek_time;
342
+ }
343
+ }
344
+ /**
345
+ * Load a new video into the player.
346
+ * @param {mep_soundcloud_load_object} content
347
+ * @param {number} startSeconds
348
+ * @param {boolean} autoplay
349
+ */
350
+ #musicLoader(content: mep_soundcloud_load_object | string, startSeconds: number, autoplay: boolean){
351
+ /*
352
+ let options = {playerVars:this.playerVars};
353
+ if(options.playerVars === undefined){
354
+ options.playerVars = {};
355
+ }
356
+ options.playerVars["autoplay"] = autoplay;
357
+ if(typeof content === "string"){
358
+ options["videoId"] = content;
359
+ }
360
+ else if (typeof content === "object"){
361
+ options["videoId"] = content["videoId"];
362
+ if(typeof startSeconds === "number"){
363
+ options["start"] = startSeconds;
364
+ }
365
+ else if(typeof content["startSeconds"] === "number"){
366
+ options["start"] = content["startSeconds"];
367
+ }
368
+ if(typeof content["endSeconds"] === "number"){
369
+ options["end"] = content["endSeconds"];
370
+ }
371
+ }
372
+ const tmp_replace_element = document.createElement("div");
373
+ tmp_replace_element.replaceWith(this.player);
374
+ this.load(tmp_replace_element,options);
375
+ */
376
+
377
+ let url_params: any = {set(op: string, val: string){this[op]=val}}
378
+ let tflist = ["hide_related","show_comments","show_user","show_user","show_reposts","visual"];
379
+ if(this.playerVars && typeof this.playerVars==="object"){
380
+ tflist.forEach(option=>{
381
+ if(this.playerVars && typeof this.playerVars[option] === "string"&&this.playerVars[option] === "true"){
382
+ url_params.set(option,"true");
383
+ }
384
+ else{
385
+ url_params.set(option,"false");
386
+ }
387
+ });
388
+ }
389
+ else{
390
+ tflist.forEach(option=>{url_params.set(option,"false");});
391
+ }
392
+ url_params.set("autoplay",autoplay?"true":"false");
393
+ this.autoplay = autoplay;
394
+ let musicId = "";
395
+ if(typeof content === "object"){
396
+ musicId = content.videoId;
397
+ if(typeof content.startSeconds=="number"&&!Number.isNaN(content.startSeconds)){
398
+ this.first_seek_time = content.startSeconds;
399
+ }
400
+ else{
401
+ this.first_seek_time = -1;
402
+ }
403
+ if(typeof content.endSeconds=="number"&&!Number.isNaN(content.endSeconds)){
404
+ this.endSeconds = content.endSeconds;
405
+ }
406
+ else{
407
+ this.endSeconds = -1;
408
+ }
409
+ }
410
+ else if(typeof content === "string"){
411
+ musicId = content;
412
+ if(typeof startSeconds === "number" && !Number.isNaN(startSeconds)){
413
+ this.first_seek_time = startSeconds;
414
+ }
415
+ else{
416
+ this.first_seek_time = -1;
417
+ }
418
+ this.endSeconds = -1;
419
+ }
420
+ else{
421
+ this.player.dispatchEvent(new CustomEvent("onError",{detail:{code:401}}));
422
+ }
423
+ if((window as any).mep_soundcloud.numericRegex.test(musicId)){
424
+ this.player_widget.load(`https://api.soundcloud.com/tracks/${String(musicId)}`,url_params,this.#ready_function);
425
+ }
426
+ else{
427
+ this.player_widget.load(`https://soundcloud.com/${String(musicId)}`,url_params,this.#ready_function);
428
+ }
429
+ this.retry_count = 0;
430
+ this.forse_pause = false;
431
+ this.#ready_function(true);
432
+ }
433
+ /**
434
+ * Load a new video into the player.With autoplay
435
+ * @param {mep_soundcloud_load_object} content
436
+ * @param {number} startSeconds
437
+ */
438
+ loadVideoById(content: mep_soundcloud_load_object | string, startSeconds: number){
439
+ this.#musicLoader(content,startSeconds,true);
440
+ }
441
+ /**
442
+ * Load a new video into the player.Without autoplay
443
+ * @param {mep_soundcloud_load_object} content
444
+ * @param {number} startSeconds
445
+ */
446
+ cueVideoById(content: mep_soundcloud_load_object | string, startSeconds: number){
447
+ this.#musicLoader(content,startSeconds,false);
448
+ }
449
+ }
450
+ (window as any).mep_soundcloud = mep_soundcloud;