multi_embed_player 3.2.4 → 3.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _multi_embed_player_instances, _multi_embed_player_check_image_status, _multi_embed_player_add_iframe, _multi_embed_player_mep_imageurl, _multi_embed_player_GDPR_accept, _multi_embed_player_error_event_handler, _multi_embed_player_setEvent, _multi_embed_player_deleteEvent, _multi_embed_player_PlayOnPlayer, _multi_embed_player_addPlaylist;
7
+ var _multi_embed_player_instances, _a, _multi_embed_player_load_applemusic_api_class, _multi_embed_player_applemusic_options_from_attributes, _multi_embed_player_check_image_status, _multi_embed_player_add_iframe, _multi_embed_player_mep_imageurl, _multi_embed_player_GDPR_accept, _multi_embed_player_error_event_handler, _multi_embed_player_setEvent, _multi_embed_player_deleteEvent, _multi_embed_player_PlayOnPlayer, _multi_embed_player_addPlaylist;
8
8
  /**
9
9
  * Fetches the iframe API for a given service and video ID.
10
10
  * @param {string} service - The name of the service.
@@ -16,10 +16,31 @@ var _multi_embed_player_instances, _multi_embed_player_check_image_status, _mult
16
16
  * @param {HTMLElement} failed_send_error_target - The target to send the error to.
17
17
  * @returns {Promise}
18
18
  */
19
- const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, image_proxy, GDPR_access_accept, failed_send_error = false, failed_send_error_target = null) => {
19
+ const multi_embed_player_applemusic_cache_key = (videoid, options) => {
20
+ return `${options?.kind || "songs"}:${options?.storefront || ""}:${videoid}`;
21
+ };
22
+ const multi_embed_player_iframe_api_cache_key = (service, videoid, options) => {
23
+ if (service === "applemusic") {
24
+ return multi_embed_player_applemusic_cache_key(videoid, options);
25
+ }
26
+ return videoid;
27
+ };
28
+ const multi_embed_player_applemusic_query = (options) => {
29
+ const params = new URLSearchParams();
30
+ if (options?.kind) {
31
+ params.set("kind", options.kind);
32
+ }
33
+ if (options?.storefront) {
34
+ params.set("storefront", options.storefront);
35
+ }
36
+ const query = params.toString();
37
+ return query === "" ? "" : `&${query}`;
38
+ };
39
+ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, image_proxy, GDPR_access_accept, failed_send_error = false, failed_send_error_target = null, options) => {
20
40
  const xml_first_search = (data, search_string, start = 0) => {
21
41
  return data.substring(data.indexOf("<" + search_string + ">", start) + search_string.length + 2, data.indexOf("</" + search_string + ">", start));
22
42
  };
43
+ const cacheKey = multi_embed_player_iframe_api_cache_key(service, videoid, options);
23
44
  const possible_direct_access = GDPR_access_accept && multi_embed_player.possible_direct_access_services.includes(service);
24
45
  if (use_cors || possible_direct_access) {
25
46
  let url = "";
@@ -33,13 +54,13 @@ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, i
33
54
  url = `${multi_embed_player.iframe_api_endpoint}?route=url_proxy&url=`;
34
55
  }
35
56
  let first_access = false;
36
- if (multi_embed_player.api_promise[service][videoid] === undefined) {
37
- multi_embed_player.api_promise[service][videoid] = { res: [], rej: [] };
57
+ if (multi_embed_player.api_promise[service][cacheKey] === undefined) {
58
+ multi_embed_player.api_promise[service][cacheKey] = { res: [], rej: [] };
38
59
  first_access = true;
39
60
  }
40
61
  else {
41
62
  await new Promise((resolve, reject) => {
42
- const promiseData = multi_embed_player.api_promise[service][videoid];
63
+ const promiseData = multi_embed_player.api_promise[service][cacheKey];
43
64
  if (promiseData) {
44
65
  promiseData.res.push(resolve);
45
66
  promiseData.rej.push(reject);
@@ -61,7 +82,7 @@ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, i
61
82
  const oembed_response_fetch = await fetch(url + encodeURI(url_oembed));
62
83
  let oembed_response = await oembed_response_fetch.json();
63
84
  oembed_response["image_base64"] = url + oembed_response["thumbnail_url"];
64
- multi_embed_player.api_cache[service][videoid] = oembed_response;
85
+ multi_embed_player.api_cache[service][cacheKey] = oembed_response;
65
86
  break;
66
87
  case 'niconico':
67
88
  const xml_response = await (await fetch(url + `https://ext.nicovideo.jp/api/getthumbinfo/${videoid}`)).text();
@@ -86,7 +107,7 @@ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, i
86
107
  }
87
108
  });
88
109
  }
89
- multi_embed_player.api_cache[service][videoid] = return_data;
110
+ multi_embed_player.api_cache[service][cacheKey] = return_data;
90
111
  break;
91
112
  case 'bilibili':
92
113
  let json_response_bilibili = await (await fetch(url + `https://api.bilibili.com/x/web-interface/view?bvid=${videoid}`)).json();
@@ -96,46 +117,46 @@ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, i
96
117
  else {
97
118
  json_response_bilibili["image_base64"] = url + json_response_bilibili.data.pic;
98
119
  }
99
- multi_embed_player.api_cache[service][videoid] = json_response_bilibili;
120
+ multi_embed_player.api_cache[service][cacheKey] = json_response_bilibili;
100
121
  break;
101
122
  case "youtube":
102
123
  try {
103
124
  let json_response_youtube = await (await fetch(url + `https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${videoid}&format=json`)).json();
104
125
  json_response_youtube["image_base64"] = url + json_response_youtube["thumbnail_url"];
105
- multi_embed_player.api_cache[service][videoid] = json_response_youtube;
126
+ multi_embed_player.api_cache[service][cacheKey] = json_response_youtube;
106
127
  }
107
128
  catch {
108
- multi_embed_player.api_cache[service][videoid] = {};
129
+ multi_embed_player.api_cache[service][cacheKey] = {};
109
130
  }
110
131
  break;
111
132
  }
112
- multi_embed_player.api_promise[service][videoid].res.forEach((resolve) => resolve(undefined));
133
+ multi_embed_player.api_promise[service][cacheKey].res.forEach((resolve) => resolve(undefined));
113
134
  }
114
135
  }
115
136
  catch {
116
- const promiseData = multi_embed_player.api_promise[service][videoid];
137
+ const promiseData = multi_embed_player.api_promise[service][cacheKey];
117
138
  if (promiseData && Object.keys(promiseData).includes("rej")) {
118
139
  promiseData.rej.forEach((reject) => reject());
119
140
  }
120
141
  if (failed_send_error && failed_send_error_target != null) {
121
142
  failed_send_error_target.dispatchEvent(new CustomEvent("onError", { detail: { code: 1100 } }));
122
143
  }
123
- multi_embed_player.api_cache[service][videoid] = {};
144
+ multi_embed_player.api_cache[service][cacheKey] = {};
124
145
  }
125
146
  }
126
147
  else {
127
148
  let fetch_response;
128
149
  try {
129
- const url = `${multi_embed_player.iframe_api_endpoint}?route=${service}&videoid=${videoid}` + (image_proxy ? "&image_base64=1" : "");
130
- if (multi_embed_player.api_promise[service][videoid] === undefined) {
131
- multi_embed_player.api_promise[service][videoid] = { res: [], rej: [] };
150
+ const url = `${multi_embed_player.iframe_api_endpoint}?route=${service}&videoid=${videoid}` + (image_proxy ? "&image_base64=1" : "") + multi_embed_player_applemusic_query(options);
151
+ if (multi_embed_player.api_promise[service][cacheKey] === undefined) {
152
+ multi_embed_player.api_promise[service][cacheKey] = { res: [], rej: [] };
132
153
  fetch_response = await fetch(url);
133
- multi_embed_player.api_cache[service][videoid] = await fetch_response.json();
134
- multi_embed_player.api_promise[service][videoid].res.forEach((resolve) => resolve(undefined));
154
+ multi_embed_player.api_cache[service][cacheKey] = await fetch_response.json();
155
+ multi_embed_player.api_promise[service][cacheKey].res.forEach((resolve) => resolve(undefined));
135
156
  }
136
157
  else {
137
158
  await new Promise((resolve, reject) => {
138
- const promiseData = multi_embed_player.api_promise[service][videoid];
159
+ const promiseData = multi_embed_player.api_promise[service][cacheKey];
139
160
  if (promiseData) {
140
161
  promiseData.res.push(resolve);
141
162
  promiseData.rej.push(reject);
@@ -144,7 +165,7 @@ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, i
144
165
  }
145
166
  }
146
167
  catch (e) {
147
- const promiseData = multi_embed_player.api_promise[service][videoid];
168
+ const promiseData = multi_embed_player.api_promise[service][cacheKey];
148
169
  if (promiseData && Object.keys(promiseData).includes("rej")) {
149
170
  promiseData.rej.forEach((reject) => reject());
150
171
  }
@@ -152,7 +173,7 @@ const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, i
152
173
  failed_send_error_target.dispatchEvent(new CustomEvent("onError", { detail: { code: 1100 } }));
153
174
  }
154
175
  else {
155
- multi_embed_player.api_cache[service][videoid] = {};
176
+ multi_embed_player.api_cache[service][cacheKey] = {};
156
177
  }
157
178
  }
158
179
  }
@@ -169,6 +190,14 @@ const multi_embed_player_GDPR_accepted_all_back_down = () => {
169
190
  * @extends HTMLElement
170
191
  */
171
192
  class multi_embed_player extends HTMLElement {
193
+ static async authorizeAppleMusic(options) {
194
+ await __classPrivateFieldGet(_a, _a, "m", _multi_embed_player_load_applemusic_api_class).call(_a);
195
+ return await window.mep_applemusic.authorizeAppleMusic(options);
196
+ }
197
+ static async getAppleMusicAuthorizationStatus() {
198
+ await __classPrivateFieldGet(_a, _a, "m", _multi_embed_player_load_applemusic_api_class).call(_a);
199
+ return await window.mep_applemusic.getAuthorizationStatus();
200
+ }
172
201
  constructor() {
173
202
  super();
174
203
  _multi_embed_player_instances.add(this);
@@ -183,7 +212,7 @@ class multi_embed_player extends HTMLElement {
183
212
  this.startSeconds = 0;
184
213
  this.endSeconds = -1;
185
214
  this.videoid = null;
186
- this.follow_GDPR = multi_embed_player.follow_GDPR;
215
+ this.follow_GDPR = _a.follow_GDPR;
187
216
  }
188
217
  async connectedCallback() {
189
218
  if (this.getAttribute("follow_GDPR") === "true") {
@@ -202,7 +231,7 @@ class multi_embed_player extends HTMLElement {
202
231
  }
203
232
  else {
204
233
  if (this.videoid && this.service) {
205
- this.image_url = await __classPrivateFieldGet(this, _multi_embed_player_instances, "m", _multi_embed_player_mep_imageurl).call(this, this.videoid, this.service);
234
+ this.image_url = await __classPrivateFieldGet(this, _multi_embed_player_instances, "m", _multi_embed_player_mep_imageurl).call(this, this.videoid, this.service, null, __classPrivateFieldGet(this, _multi_embed_player_instances, "m", _multi_embed_player_applemusic_options_from_attributes).call(this));
206
235
  }
207
236
  else {
208
237
  this.image_url = null;
@@ -324,15 +353,24 @@ class multi_embed_player extends HTMLElement {
324
353
  }
325
354
  this.setAttribute("videoid", data.videoId); //いらないけど勘違い防止用に
326
355
  this.setAttribute("service", data.service);
356
+ if (data.kind != undefined) {
357
+ this.setAttribute("kind", data.kind);
358
+ }
359
+ if (data.storefront != undefined) {
360
+ this.setAttribute("storefront", data.storefront);
361
+ }
327
362
  if (this.service && Object.keys(window.multi_embed_player.mep_load_api_promise).includes(this.service)) {
328
363
  await this.iframe_api_loader(this.service);
329
364
  if (service_changed == false) {
330
365
  //動画idを変えてiframeを再読み込み
331
366
  if (autoplay) {
332
- this.player.loadVideoById(data);
367
+ await this.player.loadVideoById(data);
368
+ if (this.service === "applemusic") {
369
+ await this.player.playVideo();
370
+ }
333
371
  }
334
372
  else {
335
- this.player.cueVideoById(data);
373
+ await this.player.cueVideoById(data);
336
374
  }
337
375
  }
338
376
  else {
@@ -356,6 +394,12 @@ class multi_embed_player extends HTMLElement {
356
394
  "height": "315",
357
395
  "playerVars": playerVars
358
396
  };
397
+ if (data.kind != undefined) {
398
+ player_argument["kind"] = data.kind;
399
+ }
400
+ if (data.storefront != undefined) {
401
+ player_argument["storefront"] = data.storefront;
402
+ }
359
403
  if (this.service == "bilibili" && this.getAttribute("play_control_wrap") === "false") {
360
404
  player_argument["play_control_wrap"] = false;
361
405
  }
@@ -365,6 +409,9 @@ class multi_embed_player extends HTMLElement {
365
409
  if (this.service) {
366
410
  this.player = new window.multi_embed_player.iframe_api_class[this.service](divdoc, player_argument, __classPrivateFieldGet(this, _multi_embed_player_instances, "m", _multi_embed_player_setEvent).bind(this));
367
411
  this.player.service = this.service;
412
+ if (this.service === "applemusic" && autoplay) {
413
+ await this.player.playVideo();
414
+ }
368
415
  }
369
416
  }
370
417
  }
@@ -458,14 +505,20 @@ class multi_embed_player extends HTMLElement {
458
505
  * Returns the real duration of the video based on the start and end seconds.
459
506
  * @returns {number} The real duration of the video.
460
507
  */
461
- getRealDulation() {
508
+ getRealDuration() {
462
509
  if (this.service && Object.keys(window.multi_embed_player.mep_load_api_promise).includes(this.service)) {
510
+ if (typeof this.player.getRealDuration === "function") {
511
+ return this.player.getRealDuration();
512
+ }
463
513
  return this.player.getRealDulation();
464
514
  }
465
515
  else {
466
516
  return 0;
467
517
  }
468
518
  }
519
+ getRealDulation() {
520
+ return this.getRealDuration();
521
+ }
469
522
  /**
470
523
  * Returns the relative current time by subtracting the start time from the current time.
471
524
  * @returns {Promise<number>} The relative current time.
@@ -477,8 +530,11 @@ class multi_embed_player extends HTMLElement {
477
530
  * Calculates the percentage of the current time relative to the total duration of the media.
478
531
  * @returns {number} The percentage of the current time.
479
532
  */
533
+ async getPercentOfCurrentTime() {
534
+ return ((await this.getRelativeCurrentTime()) / await this.getRealDuration()) * 100;
535
+ }
480
536
  async getPercentOfCurremtTime() {
481
- return ((await this.getRelativeCurrentTime()) / this.getRealDulation()) * 100;
537
+ return await this.getPercentOfCurrentTime();
482
538
  }
483
539
  /**
484
540
  * Seeks to a relative position in the video based on the current time.
@@ -559,6 +615,9 @@ class multi_embed_player extends HTMLElement {
559
615
  case "soundcloud":
560
616
  window.multi_embed_player.iframe_api_class["soundcloud"] = mep_soundcloud;
561
617
  break;
618
+ case "applemusic":
619
+ window.multi_embed_player.iframe_api_class["applemusic"] = window.mep_applemusic;
620
+ break;
562
621
  }
563
622
  window.multi_embed_player.mep_load_api_promise[service].forEach((func) => func());
564
623
  resolve();
@@ -591,7 +650,53 @@ class multi_embed_player extends HTMLElement {
591
650
  });
592
651
  }
593
652
  }
594
- _multi_embed_player_instances = new WeakSet(), _multi_embed_player_check_image_status =
653
+ _a = multi_embed_player, _multi_embed_player_instances = new WeakSet(), _multi_embed_player_load_applemusic_api_class = async function _multi_embed_player_load_applemusic_api_class() {
654
+ return new Promise((resolve, reject) => {
655
+ if (window.mep_applemusic !== undefined) {
656
+ resolve();
657
+ return;
658
+ }
659
+ if (_a.applemusic_api_loaded === 0) {
660
+ _a.applemusic_api_loaded = 1;
661
+ const script_document = document.createElement("script");
662
+ script_document.src = `${_a.script_origin}iframe_api/applemusic.js`;
663
+ script_document.async = true;
664
+ script_document.addEventListener("load", () => {
665
+ _a.applemusic_api_loaded = 2;
666
+ const promise_queue = _a.applemusic_api_promise ?? [];
667
+ _a.applemusic_api_promise = [];
668
+ promise_queue.forEach((func) => func.resolve());
669
+ resolve();
670
+ }, { once: true });
671
+ script_document.addEventListener("error", () => {
672
+ _a.applemusic_api_loaded = 0;
673
+ const promise_queue = _a.applemusic_api_promise ?? [];
674
+ _a.applemusic_api_promise = [];
675
+ promise_queue.forEach((func) => func.reject());
676
+ reject();
677
+ }, { once: true });
678
+ document.body.appendChild(script_document);
679
+ }
680
+ else if (_a.applemusic_api_loaded === 1) {
681
+ _a.applemusic_api_promise ?? (_a.applemusic_api_promise = []);
682
+ _a.applemusic_api_promise.push({ resolve: resolve, reject: reject });
683
+ }
684
+ else {
685
+ resolve();
686
+ }
687
+ });
688
+ }, _multi_embed_player_applemusic_options_from_attributes = function _multi_embed_player_applemusic_options_from_attributes() {
689
+ const options = {};
690
+ const kind = this.getAttribute("kind");
691
+ const storefront = this.getAttribute("storefront");
692
+ if (kind === "songs") {
693
+ options.kind = kind;
694
+ }
695
+ if (storefront != null) {
696
+ options.storefront = storefront;
697
+ }
698
+ return options;
699
+ }, _multi_embed_player_check_image_status =
595
700
  /**
596
701
  * Checks the status of an image URL.
597
702
  * @async
@@ -619,6 +724,14 @@ async function _multi_embed_player_add_iframe(e = null, sub = false) {
619
724
  if (this.getAttribute("end") != null) {
620
725
  content.endSeconds = Number(this.getAttribute("end"));
621
726
  }
727
+ const kind = this.getAttribute("kind");
728
+ const storefront = this.getAttribute("storefront");
729
+ if (kind === "songs") {
730
+ content.kind = kind;
731
+ }
732
+ if (storefront != null) {
733
+ content.storefront = storefront;
734
+ }
622
735
  if (this.getAttribute("subvideoid") != null && this.getAttribute("subservice") != null) {
623
736
  content.subVideoid = this.getAttribute("subvideoid") || undefined;
624
737
  content.subService = this.getAttribute("subservice");
@@ -633,7 +746,7 @@ async function _multi_embed_player_add_iframe(e = null, sub = false) {
633
746
  * @param {string} [filetype=null] - The type of file to fetch.
634
747
  * @returns {Promise<string>} - A promise that resolves with the image URL.
635
748
  */
636
- async function _multi_embed_player_mep_imageurl(videoid, service, filetype = null) {
749
+ async function _multi_embed_player_mep_imageurl(videoid, service, filetype = null, options) {
637
750
  let GDPR_accepted = false;
638
751
  if (!this.follow_GDPR) {
639
752
  GDPR_accepted = true;
@@ -658,11 +771,12 @@ async function _multi_embed_player_mep_imageurl(videoid, service, filetype = nul
658
771
  if (window.multi_embed_player.cors_proxy !== "") {
659
772
  use_cors = true;
660
773
  }
661
- if (!GDPR_accepted || service === "bilibili") { //if follow gdpr or bilibili(bilibili don't allow to fetch thumbnail from crossorigin)
662
- if (!(videoid in window.multi_embed_player.api_cache[service])) {
663
- await multi_embed_player_fetch_iframe_api(service, videoid, use_cors, true, false);
774
+ const cacheKey = multi_embed_player_iframe_api_cache_key(service, videoid, options);
775
+ if (!GDPR_accepted || service === "bilibili" || service === "applemusic") { //if follow gdpr or bilibili(bilibili don't allow to fetch thumbnail from crossorigin)
776
+ if (!(cacheKey in window.multi_embed_player.api_cache[service])) {
777
+ await multi_embed_player_fetch_iframe_api(service, videoid, service === "applemusic" ? false : use_cors, true, false, false, null, options);
664
778
  }
665
- return window.multi_embed_player.api_cache[service][videoid]["image_base64"];
779
+ return window.multi_embed_player.api_cache[service][cacheKey]["image_base64"] || window.multi_embed_player.api_cache[service][cacheKey]["thumbnail_url"];
666
780
  }
667
781
  /*else if(service==="niconico"){
668
782
  if(!(videoid in (window as any).multi_embed_player.api_cache[service])){
@@ -671,14 +785,14 @@ async function _multi_embed_player_mep_imageurl(videoid, service, filetype = nul
671
785
  return image_url + (window as any).multi_embed_player.api_cache[service][videoid]["image"];
672
786
  }*/
673
787
  else if (service === "soundcloud" || service === "youtube" || service === "niconico") {
674
- if (!(videoid in window.multi_embed_player.api_cache[service])) {
788
+ if (!(cacheKey in window.multi_embed_player.api_cache[service])) {
675
789
  await multi_embed_player_fetch_iframe_api(service, videoid, use_cors, !GDPR_accepted, GDPR_accepted);
676
790
  }
677
791
  if (!GDPR_accepted) {
678
- return window.multi_embed_player.api_cache[service][videoid]["image_base64"];
792
+ return window.multi_embed_player.api_cache[service][cacheKey]["image_base64"];
679
793
  }
680
794
  else {
681
- return window.multi_embed_player.api_cache[service][videoid]["thumbnail_url"];
795
+ return window.multi_embed_player.api_cache[service][cacheKey]["thumbnail_url"];
682
796
  }
683
797
  }
684
798
  else {
@@ -766,6 +880,9 @@ async function _multi_embed_player_GDPR_accept(service) {
766
880
  }
767
881
  }, _multi_embed_player_deleteEvent = function _multi_embed_player_deleteEvent() {
768
882
  try {
883
+ if (typeof this.player?.destroy === "function") {
884
+ this.player.destroy();
885
+ }
769
886
  if (this.service && Object.keys(window.multi_embed_player.mep_load_api_promise).includes(this.service)) {
770
887
  this.player.player.removeEventListener("onReady", () => { this.dispatchEvent(new Event("onReady")); }); //need bind
771
888
  this.player.player.removeEventListener("onError", (e) => { __classPrivateFieldGet(this, _multi_embed_player_instances, "m", _multi_embed_player_error_event_handler).call(this, e); });
@@ -790,6 +907,14 @@ async function _multi_embed_player_GDPR_accept(service) {
790
907
  content.subVideoid = subVideoid;
791
908
  content.subService = subService;
792
909
  }
910
+ const kind = this.getAttribute("kind");
911
+ const storefront = this.getAttribute("storefront");
912
+ if (kind === "songs") {
913
+ content.kind = kind;
914
+ }
915
+ if (storefront != null) {
916
+ content.storefront = storefront;
917
+ }
793
918
  playdoc.loadVideoById(content.toData());
794
919
  }, _multi_embed_player_addPlaylist = function _multi_embed_player_addPlaylist() {
795
920
  let k_data = new mep_playitem(this.getAttribute("service"), this.getAttribute("videoid"));
@@ -799,6 +924,14 @@ async function _multi_embed_player_GDPR_accept(service) {
799
924
  if (this.getAttribute("end") != null) {
800
925
  k_data.endSeconds = Number(this.getAttribute("end"));
801
926
  }
927
+ const kind = this.getAttribute("kind");
928
+ const storefront = this.getAttribute("storefront");
929
+ if (kind === "songs") {
930
+ k_data.kind = kind;
931
+ }
932
+ if (storefront != null) {
933
+ k_data.storefront = storefront;
934
+ }
802
935
  if (this.getAttribute("subService") != null && this.getAttribute("subVideoid") != null) {
803
936
  k_data.subService = this.getAttribute("subService");
804
937
  k_data.subVideoid = this.getAttribute("subVideoid") || undefined;
@@ -813,18 +946,20 @@ async function _multi_embed_player_GDPR_accept(service) {
813
946
  }
814
947
  };
815
948
  multi_embed_player.script_origin = "https://cdn.jsdelivr.net/npm/multi_embed_player@v3/dist/";
816
- multi_embed_player.iframe_api_endpoint = "https://iframe_api.ryokuryu.workers.dev";
817
- multi_embed_player.mep_status_load_api = { youtube: 0, niconico: 0, bilibili: 0, soundcloud: 0 };
818
- multi_embed_player.mep_load_api_promise = { youtube: [], niconico: [], bilibili: [], soundcloud: [] };
819
- multi_embed_player.api_cache = { niconico: {}, bilibili: {}, soundcloud: {}, youtube: {} };
820
- multi_embed_player.api_promise = { niconico: {}, bilibili: {}, soundcloud: {}, youtube: {} };
821
- multi_embed_player.GDPR_accept_promise = { youtube: [], niconico: [], bilibili: [], soundcloud: [] };
949
+ multi_embed_player.iframe_api_endpoint = "https://iframe-api-ts.ryokuryu.workers.dev";
950
+ multi_embed_player.mep_status_load_api = { youtube: 0, niconico: 0, bilibili: 0, soundcloud: 0, applemusic: 0 };
951
+ multi_embed_player.mep_load_api_promise = { youtube: [], niconico: [], bilibili: [], soundcloud: [], applemusic: [] };
952
+ multi_embed_player.api_cache = { niconico: {}, bilibili: {}, soundcloud: {}, youtube: {}, applemusic: {} };
953
+ multi_embed_player.api_promise = { niconico: {}, bilibili: {}, soundcloud: {}, youtube: {}, applemusic: {} };
954
+ multi_embed_player.GDPR_accept_promise = { youtube: [], niconico: [], bilibili: [], soundcloud: [], applemusic: [] };
822
955
  multi_embed_player.iframe_api_class = {};
823
- multi_embed_player.GDPR_accepted = { youtube: false, niconico: false, bilibili: false, soundcloud: false };
956
+ multi_embed_player.GDPR_accepted = { youtube: false, niconico: false, bilibili: false, soundcloud: false, applemusic: false };
824
957
  multi_embed_player.possible_direct_access_services = ["youtube", "soundcloud"];
825
958
  multi_embed_player.cors_proxy = ""; //if cors_proxy is not empty string,it use instead of iframe_api_endpoint and follow gdpr
826
- multi_embed_player.tearms_policy_service = { "youtube": "https://www.youtube.com/t/terms", "niconico": "https://account.nicovideo.jp/rules/account?language=en-us", "bilibili": "https://www.bilibili.com/blackboard/protocal/activity-lc1L-pIoh.html", "soundcloud": "https://soundcloud.com/pages/privacy" };
959
+ multi_embed_player.tearms_policy_service = { "youtube": "https://www.youtube.com/t/terms", "niconico": "https://account.nicovideo.jp/rules/account?language=en-us", "bilibili": "https://www.bilibili.com/blackboard/protocal/activity-lc1L-pIoh.html", "soundcloud": "https://soundcloud.com/pages/privacy", "applemusic": "https://www.apple.com/legal/internet-services/itunes/" };
827
960
  multi_embed_player.follow_GDPR = false;
961
+ multi_embed_player.applemusic_api_loaded = 0;
962
+ multi_embed_player.applemusic_api_promise = [];
828
963
  class mep_playitem {
829
964
  constructor(service, videoid) {
830
965
  this.service = service;
@@ -834,7 +969,16 @@ class mep_playitem {
834
969
  toData() {
835
970
  let content = { "service": this?.service, "videoId": this?.videoid, call_array: this.call_array, call_index: 0 };
836
971
  if (this.service !== undefined && this.videoid !== undefined) {
837
- content.call_array.push({ videoId: this.videoid, service: this.service });
972
+ const callItem = { videoId: this.videoid, service: this.service };
973
+ if (this.kind !== undefined) {
974
+ callItem.kind = this.kind;
975
+ content.kind = this.kind;
976
+ }
977
+ if (this.storefront !== undefined) {
978
+ callItem.storefront = this.storefront;
979
+ content.storefront = this.storefront;
980
+ }
981
+ content.call_array.push(callItem);
838
982
  }
839
983
  if (this.startSeconds != undefined) {
840
984
  content.startSeconds = this.startSeconds;
@@ -894,23 +1038,23 @@ const multi_embed_player_GDPR_reviever = (service) => {
894
1038
  };
895
1039
  //Add multi embed player CSS
896
1040
  const multi_embed_player_css = document.createElement("style");
897
- multi_embed_player_css.innerHTML = `
898
- multi-embed-player{
899
- display: block;
900
- position: relative;
901
- background-repeat: no-repeat;
902
- background-position: center center;
903
- background-size: cover;
904
- }
905
- multi-embed-player>iframe{
906
- width: 100%;
907
- height: 100%;
908
- }
909
- multi-embed-player>picture{
910
- position: absolute;
911
- width: 100%;
912
- height: 100%;
913
- z-index: -1;
1041
+ multi_embed_player_css.innerHTML = `
1042
+ multi-embed-player{
1043
+ display: block;
1044
+ position: relative;
1045
+ background-repeat: no-repeat;
1046
+ background-position: center center;
1047
+ background-size: cover;
1048
+ }
1049
+ multi-embed-player>iframe{
1050
+ width: 100%;
1051
+ height: 100%;
1052
+ }
1053
+ multi-embed-player>picture{
1054
+ position: absolute;
1055
+ width: 100%;
1056
+ height: 100%;
1057
+ z-index: -1;
914
1058
  }`;
915
1059
  multi_embed_player_css.classList.add("multi-embed-player-CSS");
916
1060
  document.head.appendChild(multi_embed_player_css);