multi_embed_player 3.0.1 → 3.1.1
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/CLAUDE.md +92 -0
- package/README.md +0 -24
- package/add_types.sh +61 -0
- package/dist/iframe_api/bilibili.d.ts +180 -61
- package/dist/iframe_api/bilibili.d.ts.map +1 -1
- package/dist/iframe_api/bilibili.js +938 -354
- package/dist/iframe_api/bilibili.js.map +1 -1
- package/dist/iframe_api/niconico.d.ts +177 -28
- package/dist/iframe_api/niconico.d.ts.map +1 -1
- package/dist/iframe_api/niconico.js +290 -146
- package/dist/iframe_api/niconico.js.map +1 -1
- package/dist/iframe_api/soundcloud.d.ts +132 -60
- package/dist/iframe_api/soundcloud.d.ts.map +1 -1
- package/dist/iframe_api/soundcloud.js +318 -146
- package/dist/iframe_api/soundcloud.js.map +1 -1
- package/dist/iframe_api/youtube.d.ts +32 -69
- package/dist/iframe_api/youtube.d.ts.map +1 -1
- package/dist/iframe_api/youtube.js +130 -139
- package/dist/iframe_api/youtube.js.map +1 -1
- package/dist/multi_embed_player.d.ts +193 -26
- package/dist/multi_embed_player.d.ts.map +1 -1
- package/dist/multi_embed_player.js +726 -123
- package/dist/multi_embed_player.js.map +1 -1
- package/package.json +10 -41
- package/dist/iframe_api/index.d.ts +0 -6
- package/dist/iframe_api/index.d.ts.map +0 -1
- package/dist/iframe_api/index.js +0 -8
- package/dist/iframe_api/index.js.map +0 -1
- package/dist/types.d.ts +0 -126
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -22
- package/dist/types.js.map +0 -1
|
@@ -1,76 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface Window {
|
|
4
|
-
YT: {
|
|
5
|
-
Player: new (element: string | HTMLElement, config: YTPlayerConfig) => YTPlayer;
|
|
6
|
-
ready: (callback: () => void) => void;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
interface YTPlayerConfig {
|
|
11
|
-
height: string;
|
|
12
|
-
width: string;
|
|
1
|
+
declare var YT: any;
|
|
2
|
+
interface MepYoutubeLoadObject {
|
|
13
3
|
videoId: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
events: {
|
|
17
|
-
onReady: () => void;
|
|
18
|
-
onError: (event: {
|
|
19
|
-
data: number;
|
|
20
|
-
}) => void;
|
|
21
|
-
onStateChange: () => void;
|
|
22
|
-
};
|
|
4
|
+
startSeconds?: number;
|
|
5
|
+
endSeconds?: number;
|
|
23
6
|
}
|
|
24
|
-
interface
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
isMuted(): boolean;
|
|
35
|
-
getPlayerState(): number;
|
|
36
|
-
loadVideoById(videoId: string, startSeconds?: number, suggestedQuality?: string): void;
|
|
37
|
-
cueVideoById(videoId: string, startSeconds?: number, suggestedQuality?: string): void;
|
|
7
|
+
interface MepYoutubePlayerVars {
|
|
8
|
+
autoplay?: number;
|
|
9
|
+
startSeconds?: number;
|
|
10
|
+
endSeconds?: number;
|
|
11
|
+
}
|
|
12
|
+
interface MepYoutubeContent {
|
|
13
|
+
videoId: string;
|
|
14
|
+
playerVars?: MepYoutubePlayerVars;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
38
17
|
}
|
|
39
18
|
/**
|
|
40
19
|
* Class representing a YouTube player.
|
|
41
20
|
*/
|
|
42
|
-
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* Load YouTube Iframe API asynchronously.
|
|
53
|
-
*/
|
|
54
|
-
private load_youtube_api;
|
|
21
|
+
declare class mep_youtube {
|
|
22
|
+
#private;
|
|
23
|
+
static youtube_api_loaded: number;
|
|
24
|
+
static youtube_api_promise: (() => void)[];
|
|
25
|
+
player: HTMLElement;
|
|
26
|
+
autoplay: number;
|
|
27
|
+
startSeconds: number;
|
|
28
|
+
endSeconds: number;
|
|
29
|
+
el: HTMLElement;
|
|
30
|
+
YT_player: any;
|
|
55
31
|
/**
|
|
56
32
|
* Create a new YouTube player instance.
|
|
57
33
|
*/
|
|
58
|
-
constructor(replacing_element: string | HTMLElement, content:
|
|
59
|
-
/**
|
|
60
|
-
* Load the YouTube player.
|
|
61
|
-
*/
|
|
62
|
-
private load;
|
|
63
|
-
/**
|
|
64
|
-
* Handle error events from the player.
|
|
65
|
-
*/
|
|
66
|
-
private error_event_handler;
|
|
34
|
+
constructor(replacing_element: string | HTMLElement, content: MepYoutubeContent, player_set_event_function?: (player: HTMLElement) => void);
|
|
67
35
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
private dispatch_event;
|
|
71
|
-
/**
|
|
72
|
-
* Play the video.
|
|
73
|
-
*/
|
|
36
|
+
* Play the video.
|
|
37
|
+
*/
|
|
74
38
|
playVideo(): void;
|
|
75
39
|
/**
|
|
76
40
|
* Pause the video.
|
|
@@ -101,8 +65,8 @@ export declare class mep_youtube implements IPlayer {
|
|
|
101
65
|
*/
|
|
102
66
|
mute(): void;
|
|
103
67
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
68
|
+
* Unmute the player.
|
|
69
|
+
*/
|
|
106
70
|
unMute(): void;
|
|
107
71
|
/**
|
|
108
72
|
* Check if the player is muted.
|
|
@@ -115,7 +79,7 @@ export declare class mep_youtube implements IPlayer {
|
|
|
115
79
|
/**
|
|
116
80
|
* Get the current state of the player.
|
|
117
81
|
*/
|
|
118
|
-
getPlayerState():
|
|
82
|
+
getPlayerState(): number;
|
|
119
83
|
/**
|
|
120
84
|
* Get the title of the currently loaded video.
|
|
121
85
|
*/
|
|
@@ -123,11 +87,10 @@ export declare class mep_youtube implements IPlayer {
|
|
|
123
87
|
/**
|
|
124
88
|
* Load a new video by ID.
|
|
125
89
|
*/
|
|
126
|
-
loadVideoById(content:
|
|
90
|
+
loadVideoById(content: MepYoutubeLoadObject | string, startSeconds?: number): void;
|
|
127
91
|
/**
|
|
128
92
|
* Cue a new video by ID.
|
|
129
93
|
*/
|
|
130
|
-
cueVideoById(content:
|
|
94
|
+
cueVideoById(content: MepYoutubeLoadObject | string, startSeconds?: number): void;
|
|
131
95
|
}
|
|
132
|
-
export {};
|
|
133
96
|
//# sourceMappingURL=youtube.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"youtube.d.ts","sourceRoot":"","sources":["../../iframe_api/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"youtube.d.ts","sourceRoot":"","sources":["../../iframe_api/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC;AAMpB,UAAU,oBAAoB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,oBAAoB;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,iBAAiB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,cAAM,WAAW;;IACb,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAK;IACtC,MAAM,CAAC,mBAAmB,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAM;IAEhD,MAAM,EAAE,WAAW,CAAiC;IACpD,QAAQ,EAAE,MAAM,CAAK;IACrB,YAAY,EAAE,MAAM,CAAK;IACzB,UAAU,EAAE,MAAM,CAAM;IACxB,EAAE,EAAE,WAAW,CAAiC;IAChD,SAAS,EAAE,GAAG,CAAC;IAyBf;;OAEG;gBACS,iBAAiB,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI;IAgFzI;;MAEE;IACH,SAAS;IAIT;;OAEG;IACH,UAAU;IAIV;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,eAAe,IAAI,MAAM;IASzB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAa1B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAS/B;;OAEG;IACH,IAAI;IAIH;;MAEE;IACH,MAAM;IAIN;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,cAAc,IAAI,MAAM;IAuBxB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IASlF;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;CAoBpF"}
|
|
@@ -1,142 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _mep_youtube_instances, _mep_youtube_load_youtube_api, _mep_youtube_load, _mep_youtube_error_event_handler, _mep_youtube_dispatchEvent;
|
|
2
8
|
/**
|
|
3
9
|
* Class representing a YouTube player.
|
|
4
10
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Load YouTube Iframe API asynchronously.
|
|
8
|
-
*/
|
|
9
|
-
async load_youtube_api() {
|
|
10
|
-
return new Promise((resolve) => {
|
|
11
|
-
if (mep_youtube.youtube_api_loaded === 0) {
|
|
12
|
-
mep_youtube.youtube_api_loaded = 1;
|
|
13
|
-
const script_doc = document.createElement("script");
|
|
14
|
-
script_doc.src = "https://www.youtube.com/iframe_api";
|
|
15
|
-
script_doc.addEventListener("load", () => {
|
|
16
|
-
window.YT.ready(() => {
|
|
17
|
-
mep_youtube.youtube_api_promise.forEach(func => func());
|
|
18
|
-
mep_youtube.youtube_api_loaded = 2;
|
|
19
|
-
resolve();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
document.body.appendChild(script_doc);
|
|
23
|
-
}
|
|
24
|
-
else if (mep_youtube.youtube_api_loaded === 1) {
|
|
25
|
-
mep_youtube.youtube_api_promise.push(resolve);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
resolve();
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
11
|
+
class mep_youtube {
|
|
32
12
|
/**
|
|
33
13
|
* Create a new YouTube player instance.
|
|
34
14
|
*/
|
|
35
15
|
constructor(replacing_element, content, player_set_event_function) {
|
|
16
|
+
_mep_youtube_instances.add(this);
|
|
17
|
+
this.player = document.createElement("div");
|
|
36
18
|
this.autoplay = 0;
|
|
37
19
|
this.startSeconds = 0;
|
|
38
20
|
this.endSeconds = -1;
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Load the YouTube player.
|
|
43
|
-
*/
|
|
44
|
-
async load(replacing_element, content, player_set_event_function) {
|
|
45
|
-
this.player = document.createElement("div"); // dummy
|
|
46
|
-
if (typeof player_set_event_function === "function") {
|
|
47
|
-
player_set_event_function();
|
|
48
|
-
}
|
|
49
|
-
await this.load_youtube_api();
|
|
50
|
-
let iframe_replace_node;
|
|
51
|
-
if (typeof replacing_element === "string") {
|
|
52
|
-
const element = document.getElementById(replacing_element);
|
|
53
|
-
if (!element) {
|
|
54
|
-
throw new Error(`Element with id "${replacing_element}" not found`);
|
|
55
|
-
}
|
|
56
|
-
iframe_replace_node = element;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
iframe_replace_node = replacing_element;
|
|
60
|
-
}
|
|
61
|
-
const playerVars = content.playerVars || {};
|
|
62
|
-
const player_vars_pass_over = {};
|
|
63
|
-
this.autoplay = 0;
|
|
64
|
-
if (playerVars.autoplay) {
|
|
65
|
-
this.autoplay = 1;
|
|
66
|
-
player_vars_pass_over.autoplay = 1;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
player_vars_pass_over.autoplay = 0;
|
|
70
|
-
}
|
|
71
|
-
this.startSeconds = 0;
|
|
72
|
-
this.endSeconds = -1;
|
|
73
|
-
if (playerVars.startSeconds) {
|
|
74
|
-
this.startSeconds = playerVars.startSeconds;
|
|
75
|
-
player_vars_pass_over.start = playerVars.startSeconds;
|
|
76
|
-
}
|
|
77
|
-
if (playerVars.endSeconds) {
|
|
78
|
-
this.endSeconds = playerVars.endSeconds;
|
|
79
|
-
player_vars_pass_over.end = playerVars.endSeconds;
|
|
80
|
-
}
|
|
81
|
-
this.el = iframe_replace_node;
|
|
82
|
-
this.YT_player = new window.YT.Player(iframe_replace_node, {
|
|
83
|
-
height: "315",
|
|
84
|
-
width: "560",
|
|
85
|
-
videoId: content.videoId,
|
|
86
|
-
playerVars: player_vars_pass_over,
|
|
87
|
-
host: "https://www.youtube-nocookie.com",
|
|
88
|
-
events: {
|
|
89
|
-
onReady: () => {
|
|
90
|
-
this.dispatch_event(new Event("onReady"));
|
|
91
|
-
},
|
|
92
|
-
onError: (e) => {
|
|
93
|
-
this.error_event_handler(e);
|
|
94
|
-
},
|
|
95
|
-
onStateChange: () => {
|
|
96
|
-
this.dispatch_event(new CustomEvent("onStateChange", { detail: this.getPlayerState() }));
|
|
97
|
-
if (this.getPlayerState() === PlayerState.ENDED) {
|
|
98
|
-
this.dispatch_event(new Event("onEndVideo"));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
if (!this.autoplay) {
|
|
104
|
-
this.player.addEventListener("onReady", () => {
|
|
105
|
-
this.pauseVideo();
|
|
106
|
-
}, { once: true });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Handle error events from the player.
|
|
111
|
-
*/
|
|
112
|
-
error_event_handler(event) {
|
|
113
|
-
let code = 520;
|
|
114
|
-
switch (event.data) {
|
|
115
|
-
case 2:
|
|
116
|
-
code = ErrorCode.INVALID_PARAMETER;
|
|
117
|
-
break;
|
|
118
|
-
case 5:
|
|
119
|
-
code = ErrorCode.HTML5_ERROR;
|
|
120
|
-
break;
|
|
121
|
-
case 100:
|
|
122
|
-
code = ErrorCode.VIDEO_NOT_FOUND;
|
|
123
|
-
break;
|
|
124
|
-
case 101:
|
|
125
|
-
case 150:
|
|
126
|
-
code = ErrorCode.EMBED_NOT_ALLOWED;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
this.player.dispatchEvent(new CustomEvent("onError", { detail: { code } }));
|
|
21
|
+
this.el = document.createElement("div");
|
|
22
|
+
__classPrivateFieldGet(this, _mep_youtube_instances, "m", _mep_youtube_load).call(this, replacing_element, content, player_set_event_function);
|
|
130
23
|
}
|
|
131
24
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
dispatch_event(event) {
|
|
135
|
-
this.player.dispatchEvent(event);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Play the video.
|
|
139
|
-
*/
|
|
25
|
+
* Play the video.
|
|
26
|
+
*/
|
|
140
27
|
playVideo() {
|
|
141
28
|
this.YT_player.playVideo();
|
|
142
29
|
}
|
|
@@ -173,7 +60,7 @@ export class mep_youtube {
|
|
|
173
60
|
* Seek to a specific time in the video.
|
|
174
61
|
*/
|
|
175
62
|
seekTo(time) {
|
|
176
|
-
//
|
|
63
|
+
//try to time as number
|
|
177
64
|
time = Number(time);
|
|
178
65
|
if (isNaN(time)) {
|
|
179
66
|
console.error("time is not a number(Nan error)");
|
|
@@ -202,8 +89,8 @@ export class mep_youtube {
|
|
|
202
89
|
this.YT_player.mute();
|
|
203
90
|
}
|
|
204
91
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
92
|
+
* Unmute the player.
|
|
93
|
+
*/
|
|
207
94
|
unMute() {
|
|
208
95
|
this.YT_player.unMute();
|
|
209
96
|
}
|
|
@@ -225,24 +112,24 @@ export class mep_youtube {
|
|
|
225
112
|
getPlayerState() {
|
|
226
113
|
let nowstatus = this.YT_player.getPlayerState();
|
|
227
114
|
if ((this.getCurrentTime() > this.getDuration() - 1 && this.getCurrentTime() != 0 && this.getDuration() != 0) || (this.endSeconds != -1 && this.endSeconds - 1 <= this.getCurrentTime())) {
|
|
228
|
-
return
|
|
115
|
+
return 4;
|
|
229
116
|
}
|
|
230
117
|
else if (nowstatus == -1) {
|
|
231
|
-
return
|
|
118
|
+
return 0;
|
|
232
119
|
}
|
|
233
120
|
else if (nowstatus == 0) {
|
|
234
|
-
return
|
|
121
|
+
return 4;
|
|
235
122
|
}
|
|
236
123
|
else if (nowstatus == 1) {
|
|
237
|
-
return
|
|
124
|
+
return 2;
|
|
238
125
|
}
|
|
239
126
|
else if (nowstatus == 2) {
|
|
240
|
-
return
|
|
127
|
+
return 3;
|
|
241
128
|
}
|
|
242
129
|
else if (nowstatus == 3 || nowstatus == 5) {
|
|
243
|
-
return
|
|
130
|
+
return 1;
|
|
244
131
|
}
|
|
245
|
-
return
|
|
132
|
+
return 0;
|
|
246
133
|
}
|
|
247
134
|
/**
|
|
248
135
|
* Get the title of the currently loaded video.
|
|
@@ -255,7 +142,7 @@ export class mep_youtube {
|
|
|
255
142
|
*/
|
|
256
143
|
loadVideoById(content, startSeconds) {
|
|
257
144
|
if (typeof content === "object") {
|
|
258
|
-
this.YT_player.loadVideoById(content
|
|
145
|
+
this.YT_player.loadVideoById(content);
|
|
259
146
|
}
|
|
260
147
|
else {
|
|
261
148
|
this.YT_player.loadVideoById(content, startSeconds);
|
|
@@ -266,13 +153,117 @@ export class mep_youtube {
|
|
|
266
153
|
*/
|
|
267
154
|
cueVideoById(content, startSeconds) {
|
|
268
155
|
if (typeof content === "object") {
|
|
269
|
-
this.YT_player.cueVideoById(content
|
|
156
|
+
this.YT_player.cueVideoById(content);
|
|
270
157
|
}
|
|
271
158
|
else {
|
|
272
159
|
this.YT_player.cueVideoById(content, startSeconds);
|
|
273
160
|
}
|
|
274
161
|
}
|
|
275
162
|
}
|
|
163
|
+
_mep_youtube_instances = new WeakSet(), _mep_youtube_load_youtube_api =
|
|
164
|
+
/**
|
|
165
|
+
* Load YouTube Iframe API asynchronously.
|
|
166
|
+
* @returns {Promise} Promise that resolves when the API is loaded.
|
|
167
|
+
*/
|
|
168
|
+
async function _mep_youtube_load_youtube_api() {
|
|
169
|
+
return new Promise(async (resolve, reject) => {
|
|
170
|
+
if (window.mep_youtube.youtube_api_loaded === 0) {
|
|
171
|
+
window.mep_youtube.youtube_api_loaded = 1;
|
|
172
|
+
const script_doc = document.createElement("script");
|
|
173
|
+
script_doc.src = "https://www.youtube.com/iframe_api";
|
|
174
|
+
//script_doc.addEventListener("error",this.#dispatchEvent(new CustomEvent("onError",{detail:{code:1001}})));
|
|
175
|
+
script_doc.addEventListener("load", () => { YT.ready(() => { window.mep_youtube.youtube_api_promise.forEach((func) => func()); window.mep_youtube.youtube_api_loaded = 2; resolve(); }); });
|
|
176
|
+
document.body.appendChild(script_doc);
|
|
177
|
+
}
|
|
178
|
+
else if (window.mep_youtube.youtube_api_loaded == 1) {
|
|
179
|
+
window.mep_youtube.youtube_api_promise.push(resolve);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
resolve();
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}, _mep_youtube_load =
|
|
186
|
+
/**
|
|
187
|
+
* Load the YouTube player.
|
|
188
|
+
*/
|
|
189
|
+
async function _mep_youtube_load(replacing_element, content, player_set_event_function) {
|
|
190
|
+
this.player = document.createElement("div"); //dummy
|
|
191
|
+
if (typeof player_set_event_function === "function") {
|
|
192
|
+
player_set_event_function(this.player);
|
|
193
|
+
}
|
|
194
|
+
await __classPrivateFieldGet(this, _mep_youtube_instances, "m", _mep_youtube_load_youtube_api).call(this);
|
|
195
|
+
let iframe_replace_node = null;
|
|
196
|
+
if (typeof replacing_element === "string") {
|
|
197
|
+
iframe_replace_node = document.getElementById(replacing_element);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
iframe_replace_node = replacing_element;
|
|
201
|
+
}
|
|
202
|
+
const playerVars = content.playerVars || {};
|
|
203
|
+
let playerVars_pass_over = {};
|
|
204
|
+
if (playerVars.autoplay) {
|
|
205
|
+
this.autoplay = 1;
|
|
206
|
+
playerVars_pass_over.autoplay = 1;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
playerVars_pass_over.autoplay = 0;
|
|
210
|
+
}
|
|
211
|
+
if (playerVars.startSeconds) {
|
|
212
|
+
this.startSeconds = playerVars.startSeconds;
|
|
213
|
+
playerVars_pass_over.start = playerVars.startSeconds;
|
|
214
|
+
}
|
|
215
|
+
if (playerVars.endSeconds) {
|
|
216
|
+
this.endSeconds = playerVars.endSeconds;
|
|
217
|
+
playerVars_pass_over.end = playerVars.endSeconds;
|
|
218
|
+
}
|
|
219
|
+
if (iframe_replace_node) {
|
|
220
|
+
this.el = iframe_replace_node;
|
|
221
|
+
this.YT_player = new YT.Player(iframe_replace_node, {
|
|
222
|
+
height: "315",
|
|
223
|
+
width: "560",
|
|
224
|
+
videoId: content.videoId,
|
|
225
|
+
playerVars: playerVars_pass_over,
|
|
226
|
+
host: "https://www.youtube-nocookie.com",
|
|
227
|
+
events: {
|
|
228
|
+
"onReady": () => { __classPrivateFieldGet(this, _mep_youtube_instances, "m", _mep_youtube_dispatchEvent).call(this, new Event("onReady")); },
|
|
229
|
+
"onError": (e) => { __classPrivateFieldGet(this, _mep_youtube_instances, "m", _mep_youtube_error_event_handler).call(this, e); },
|
|
230
|
+
"onStateChange": () => { __classPrivateFieldGet(this, _mep_youtube_instances, "m", _mep_youtube_dispatchEvent).call(this, new CustomEvent("onStateChange", { detail: this.getPlayerState() })); if (this.getPlayerState() == 4) {
|
|
231
|
+
__classPrivateFieldGet(this, _mep_youtube_instances, "m", _mep_youtube_dispatchEvent).call(this, new Event("onEndVideo"));
|
|
232
|
+
} }
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
if (!this.autoplay) {
|
|
236
|
+
this.player.addEventListener("onReady", () => { this.pauseVideo(); }, { once: true });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, _mep_youtube_error_event_handler = function _mep_youtube_error_event_handler(event) {
|
|
240
|
+
//change status code to mep error code
|
|
241
|
+
let code = 520;
|
|
242
|
+
switch (event.data) {
|
|
243
|
+
case 2:
|
|
244
|
+
code = 401;
|
|
245
|
+
break;
|
|
246
|
+
case 5:
|
|
247
|
+
code = 500;
|
|
248
|
+
break;
|
|
249
|
+
case 100:
|
|
250
|
+
code = 404;
|
|
251
|
+
break;
|
|
252
|
+
case 101:
|
|
253
|
+
case 150:
|
|
254
|
+
code = 403;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
this.player.dispatchEvent(new CustomEvent("onError", { detail: { code: code } }));
|
|
258
|
+
}, _mep_youtube_dispatchEvent = function _mep_youtube_dispatchEvent(event) {
|
|
259
|
+
try {
|
|
260
|
+
this.player.dispatchEvent(event);
|
|
261
|
+
}
|
|
262
|
+
catch (e) {
|
|
263
|
+
console.error(e);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
276
266
|
mep_youtube.youtube_api_loaded = 0;
|
|
277
267
|
mep_youtube.youtube_api_promise = [];
|
|
268
|
+
window.mep_youtube = mep_youtube;
|
|
278
269
|
//# sourceMappingURL=youtube.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../iframe_api/youtube.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../iframe_api/youtube.ts"],"names":[],"mappings":";;;;;;;AAyBA;;GAEG;AACH,MAAM,WAAW;IAkCb;;OAEG;IACH,YAAY,iBAAuC,EAAE,OAA0B,EAAE,yBAAyD;;QAjC1I,WAAM,GAAgB,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACpD,aAAQ,GAAW,CAAC,CAAC;QACrB,iBAAY,GAAW,CAAC,CAAC;QACzB,eAAU,GAAW,CAAC,CAAC,CAAC;QACxB,OAAE,GAAgB,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QA8B5C,uBAAA,IAAI,iDAAM,MAAV,IAAI,EAAO,iBAAiB,EAAC,OAAO,EAAC,yBAAyB,CAAC,CAAC;IACpE,CAAC;IA8EA;;MAEE;IACH,SAAS;QACL,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,UAAU;QACN,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,cAAc;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,WAAW;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,eAAe;QACX,IAAG,IAAI,CAAC,UAAU,IAAE,CAAC,CAAC,EAAC,CAAC;YACpB,OAAO,I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