ts-video-player 0.1.1 → 0.1.2
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/dist/cdn.min.js +76 -76
- package/dist/{chunk-eajts2jv.js → chunk-d352kdh6.js} +215 -191
- package/dist/{chunk-z1ehbz9f.js → chunk-ds1nj487.js} +35 -35
- package/dist/{chunk-36x4yhjn.js → chunk-rhykj0qy.js} +58 -58
- package/dist/elements/index.js +49 -50
- package/dist/features/index.js +25 -26
- package/dist/index.js +368 -368
- package/dist/plugins/index.js +2143 -15
- package/dist/providers/html5.d.ts +4 -0
- package/dist/stx/index.js +4 -4
- package/dist/ui/index.js +730 -11
- package/package.json +3 -5
- package/src/providers/html5.ts +1 -1
- package/src/providers/index.ts +36 -2
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
2
|
+
StateStore2,
|
|
3
|
+
selectBufferedAmount2,
|
|
4
|
+
createStorageSync2,
|
|
5
|
+
EventEmitter2,
|
|
6
|
+
MediaEventsNormalizer2,
|
|
7
|
+
onFullscreenChange2,
|
|
8
|
+
onPiPChange2,
|
|
9
|
+
createKeyboardHandler2,
|
|
10
|
+
createActivityDetector2,
|
|
11
|
+
detectVolumeAvailability2,
|
|
12
|
+
probeVolumeAvailability2,
|
|
13
|
+
detectFullscreenAvailability2,
|
|
14
|
+
enterFullscreen2,
|
|
15
|
+
exitFullscreen2,
|
|
16
|
+
detectPipAvailability2,
|
|
17
|
+
enterPiP2,
|
|
18
|
+
exitPiP2
|
|
19
|
+
} from "./chunk-rhykj0qy.js";
|
|
20
20
|
|
|
21
21
|
// src/core/media-session.ts
|
|
22
|
-
function
|
|
22
|
+
function isMediaSessionSupported2() {
|
|
23
23
|
return typeof navigator !== "undefined" && "mediaSession" in navigator;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (!
|
|
25
|
+
function createMediaSession2(store, actions, options) {
|
|
26
|
+
if (!isMediaSessionSupported2())
|
|
27
27
|
return () => {};
|
|
28
28
|
const session = navigator.mediaSession;
|
|
29
29
|
if (options) {
|
|
30
|
-
|
|
30
|
+
updateMetadata2(options);
|
|
31
31
|
}
|
|
32
32
|
const handlers = [
|
|
33
33
|
["play", () => actions.play()],
|
|
@@ -94,8 +94,8 @@ function createMediaSession(store, actions, options) {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
if (!
|
|
97
|
+
function updateMetadata2(options) {
|
|
98
|
+
if (!isMediaSessionSupported2())
|
|
99
99
|
return;
|
|
100
100
|
navigator.mediaSession.metadata = new MediaMetadata({
|
|
101
101
|
title: options.title || "",
|
|
@@ -106,11 +106,11 @@ function updateMetadata(options) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// src/core/orientation.ts
|
|
109
|
-
function
|
|
109
|
+
function isOrientationLockSupported2() {
|
|
110
110
|
return typeof screen !== "undefined" && "orientation" in screen && typeof screen.orientation.lock === "function";
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
if (!
|
|
112
|
+
function lockOrientation2(type) {
|
|
113
|
+
if (!isOrientationLockSupported2())
|
|
114
114
|
return;
|
|
115
115
|
const orientationMap = {
|
|
116
116
|
landscape: "landscape",
|
|
@@ -119,8 +119,8 @@ function lockOrientation(type) {
|
|
|
119
119
|
};
|
|
120
120
|
screen.orientation.lock(orientationMap[type]).catch(() => {});
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
if (!
|
|
122
|
+
function unlockOrientation2() {
|
|
123
|
+
if (!isOrientationLockSupported2())
|
|
124
124
|
return;
|
|
125
125
|
try {
|
|
126
126
|
screen.orientation.unlock();
|
|
@@ -128,10 +128,10 @@ function unlockOrientation() {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// src/providers/base.ts
|
|
131
|
-
class
|
|
131
|
+
class BaseProvider2 {
|
|
132
132
|
container = null;
|
|
133
133
|
options = {};
|
|
134
|
-
events = new
|
|
134
|
+
events = new EventEmitter2;
|
|
135
135
|
_ready = false;
|
|
136
136
|
get mediaElement() {
|
|
137
137
|
return null;
|
|
@@ -173,20 +173,20 @@ class BaseProvider {
|
|
|
173
173
|
const video = el instanceof HTMLVideoElement ? el : null;
|
|
174
174
|
switch (feature) {
|
|
175
175
|
case "volume":
|
|
176
|
-
return el && !(el instanceof HTMLMediaElement) ? "available" :
|
|
176
|
+
return el && !(el instanceof HTMLMediaElement) ? "available" : detectVolumeAvailability2(media);
|
|
177
177
|
case "fullscreen":
|
|
178
|
-
return
|
|
178
|
+
return detectFullscreenAvailability2(this.container, video);
|
|
179
179
|
case "pip":
|
|
180
|
-
return el && !(el instanceof HTMLMediaElement) ? "unsupported" :
|
|
180
|
+
return el && !(el instanceof HTMLMediaElement) ? "unsupported" : detectPipAvailability2(video);
|
|
181
181
|
default:
|
|
182
182
|
return "unsupported";
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
async enterFullscreen() {
|
|
186
|
-
await
|
|
186
|
+
await enterFullscreen2(this.container, this.mediaElement);
|
|
187
187
|
}
|
|
188
188
|
async exitFullscreen() {
|
|
189
|
-
await
|
|
189
|
+
await exitFullscreen2(this.mediaElement);
|
|
190
190
|
}
|
|
191
191
|
getFullscreenElement() {
|
|
192
192
|
return this.container;
|
|
@@ -195,10 +195,10 @@ class BaseProvider {
|
|
|
195
195
|
const media = this.mediaElement;
|
|
196
196
|
if (!media)
|
|
197
197
|
return;
|
|
198
|
-
await
|
|
198
|
+
await enterPiP2(media);
|
|
199
199
|
}
|
|
200
200
|
async exitPiP() {
|
|
201
|
-
await
|
|
201
|
+
await exitPiP2(this.mediaElement);
|
|
202
202
|
}
|
|
203
203
|
on(event, handler) {
|
|
204
204
|
this.events.on(event, handler);
|
|
@@ -212,7 +212,7 @@ class BaseProvider {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
// src/providers/html5.ts
|
|
215
|
-
function
|
|
215
|
+
function isHTML5Source2(src) {
|
|
216
216
|
if (typeof src === "string") {
|
|
217
217
|
const extension = getExtension(src);
|
|
218
218
|
if (extension === "mp4" || extension === "webm" || extension === "ogg" || extension === "ogv" || extension === "mov" || extension === "mp3" || extension === "wav" || extension === "flac" || extension === "m4a" || extension === "aac" || extension === "oga" || extension === "opus") {
|
|
@@ -249,7 +249,7 @@ function getMimeType(src) {
|
|
|
249
249
|
return mimeTypes[ext || ""] || "video/mp4";
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
class
|
|
252
|
+
class HTML5Provider2 extends BaseProvider2 {
|
|
253
253
|
name = "html5";
|
|
254
254
|
type = "video";
|
|
255
255
|
media = null;
|
|
@@ -294,12 +294,12 @@ class HTML5Provider extends BaseProvider {
|
|
|
294
294
|
this.container.appendChild(this.media);
|
|
295
295
|
for (const track of this.options.tracks ?? [])
|
|
296
296
|
this.addTextTrack(track);
|
|
297
|
-
this.eventsNormalizer = new
|
|
298
|
-
this.cleanupFullscreen =
|
|
297
|
+
this.eventsNormalizer = new MediaEventsNormalizer2(this.media, this.events);
|
|
298
|
+
this.cleanupFullscreen = onFullscreenChange2((fullscreen) => {
|
|
299
299
|
this.events.emit("fullscreenchange", fullscreen);
|
|
300
300
|
});
|
|
301
301
|
if (!this.isAudio && this.media instanceof HTMLVideoElement) {
|
|
302
|
-
this.cleanupPiP =
|
|
302
|
+
this.cleanupPiP = onPiPChange2(this.media, (pip) => {
|
|
303
303
|
this.events.emit("pipchange", pip);
|
|
304
304
|
});
|
|
305
305
|
}
|
|
@@ -327,7 +327,7 @@ class HTML5Provider extends BaseProvider {
|
|
|
327
327
|
this.media.addEventListener("loadeddata", () => {
|
|
328
328
|
if (!this.media)
|
|
329
329
|
return;
|
|
330
|
-
|
|
330
|
+
probeVolumeAvailability2(this.media).then((availability) => {
|
|
331
331
|
this.events.emit("statechange", {
|
|
332
332
|
volumeAvailability: availability
|
|
333
333
|
});
|
|
@@ -357,7 +357,7 @@ class HTML5Provider extends BaseProvider {
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
canPlay(src) {
|
|
360
|
-
return
|
|
360
|
+
return isHTML5Source2(src);
|
|
361
361
|
}
|
|
362
362
|
async load(src) {
|
|
363
363
|
if (!this.media)
|
|
@@ -522,11 +522,11 @@ class HTML5Provider extends BaseProvider {
|
|
|
522
522
|
this.media.appendChild(track);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
var
|
|
525
|
+
var html5Loader2 = {
|
|
526
526
|
name: "html5",
|
|
527
527
|
type: "video",
|
|
528
528
|
canPlay(src) {
|
|
529
|
-
return
|
|
529
|
+
return isHTML5Source2(src);
|
|
530
530
|
},
|
|
531
531
|
mediaType(src) {
|
|
532
532
|
if (typeof src === "string") {
|
|
@@ -544,7 +544,7 @@ var html5Loader = {
|
|
|
544
544
|
return "video";
|
|
545
545
|
},
|
|
546
546
|
async load(container, options) {
|
|
547
|
-
const provider = new
|
|
547
|
+
const provider = new HTML5Provider2;
|
|
548
548
|
await provider.setup(container, options);
|
|
549
549
|
return provider;
|
|
550
550
|
}
|
|
@@ -555,7 +555,7 @@ var YOUTUBE_PATTERNS = [
|
|
|
555
555
|
/youtube\.com\/v\/([a-zA-Z0-9_-]{11})/,
|
|
556
556
|
/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/
|
|
557
557
|
];
|
|
558
|
-
function
|
|
558
|
+
function extractYouTubeId2(url) {
|
|
559
559
|
for (const pattern of YOUTUBE_PATTERNS) {
|
|
560
560
|
const match = url.match(pattern);
|
|
561
561
|
if (match)
|
|
@@ -563,9 +563,9 @@ function extractYouTubeId(url) {
|
|
|
563
563
|
}
|
|
564
564
|
return null;
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function isYouTubeSource2(src) {
|
|
567
567
|
if (typeof src === "string") {
|
|
568
|
-
return
|
|
568
|
+
return extractYouTubeId2(src) !== null;
|
|
569
569
|
}
|
|
570
570
|
if (typeof src === "object" && "type" in src) {
|
|
571
571
|
return src.type === "youtube";
|
|
@@ -574,7 +574,7 @@ function isYouTubeSource(src) {
|
|
|
574
574
|
}
|
|
575
575
|
function parseYouTubeSource(src) {
|
|
576
576
|
if (typeof src === "string") {
|
|
577
|
-
const videoId =
|
|
577
|
+
const videoId = extractYouTubeId2(src);
|
|
578
578
|
if (!videoId)
|
|
579
579
|
return null;
|
|
580
580
|
const url = new URL(src, "https://youtube.com");
|
|
@@ -589,7 +589,7 @@ function parseYouTubeSource(src) {
|
|
|
589
589
|
if (typeof src === "object" && "type" in src && src.type === "youtube") {
|
|
590
590
|
const ytSrc = src;
|
|
591
591
|
return {
|
|
592
|
-
videoId: ytSrc.videoId ||
|
|
592
|
+
videoId: ytSrc.videoId || extractYouTubeId2(ytSrc.src) || "",
|
|
593
593
|
startTime: ytSrc.startTime,
|
|
594
594
|
endTime: ytSrc.endTime
|
|
595
595
|
};
|
|
@@ -614,7 +614,7 @@ function parseTime(time) {
|
|
|
614
614
|
return 0;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
class
|
|
617
|
+
class YouTubeProvider2 extends BaseProvider2 {
|
|
618
618
|
name = "youtube";
|
|
619
619
|
type = "youtube";
|
|
620
620
|
player = null;
|
|
@@ -762,7 +762,7 @@ class YouTubeProvider extends BaseProvider {
|
|
|
762
762
|
this.events.emit("ratechange", this.getPlaybackRate());
|
|
763
763
|
}
|
|
764
764
|
canPlay(src) {
|
|
765
|
-
return
|
|
765
|
+
return isYouTubeSource2(src);
|
|
766
766
|
}
|
|
767
767
|
async load(src) {
|
|
768
768
|
const parsed = parseYouTubeSource(src);
|
|
@@ -869,11 +869,11 @@ class YouTubeProvider extends BaseProvider {
|
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
|
-
var
|
|
872
|
+
var youtubeLoader2 = {
|
|
873
873
|
name: "youtube",
|
|
874
874
|
type: "youtube",
|
|
875
875
|
canPlay(src) {
|
|
876
|
-
return
|
|
876
|
+
return isYouTubeSource2(src);
|
|
877
877
|
},
|
|
878
878
|
mediaType() {
|
|
879
879
|
return "video";
|
|
@@ -887,7 +887,7 @@ var youtubeLoader = {
|
|
|
887
887
|
];
|
|
888
888
|
},
|
|
889
889
|
async load(container, options) {
|
|
890
|
-
const provider = new
|
|
890
|
+
const provider = new YouTubeProvider2;
|
|
891
891
|
await provider.setup(container, options);
|
|
892
892
|
return provider;
|
|
893
893
|
}
|
|
@@ -900,7 +900,7 @@ var VIMEO_PATTERNS = [
|
|
|
900
900
|
/vimeo\.com\/channels\/[\w]+\/(\d+)/,
|
|
901
901
|
/vimeo\.com\/groups\/[\w]+\/videos\/(\d+)/
|
|
902
902
|
];
|
|
903
|
-
function
|
|
903
|
+
function extractVimeoId2(url) {
|
|
904
904
|
for (const pattern of VIMEO_PATTERNS) {
|
|
905
905
|
const match = url.match(pattern);
|
|
906
906
|
if (match)
|
|
@@ -908,13 +908,13 @@ function extractVimeoId(url) {
|
|
|
908
908
|
}
|
|
909
909
|
return null;
|
|
910
910
|
}
|
|
911
|
-
function
|
|
911
|
+
function extractVimeoHash2(url) {
|
|
912
912
|
const match = url.match(/vimeo\.com\/\d+\/([a-f0-9]+)/);
|
|
913
913
|
return match ? match[1] : null;
|
|
914
914
|
}
|
|
915
|
-
function
|
|
915
|
+
function isVimeoSource2(src) {
|
|
916
916
|
if (typeof src === "string") {
|
|
917
|
-
return
|
|
917
|
+
return extractVimeoId2(src) !== null;
|
|
918
918
|
}
|
|
919
919
|
if (typeof src === "object" && "type" in src) {
|
|
920
920
|
return src.type === "vimeo";
|
|
@@ -923,15 +923,15 @@ function isVimeoSource(src) {
|
|
|
923
923
|
}
|
|
924
924
|
function parseVimeoSource(src) {
|
|
925
925
|
if (typeof src === "string") {
|
|
926
|
-
const videoId =
|
|
926
|
+
const videoId = extractVimeoId2(src);
|
|
927
927
|
if (!videoId)
|
|
928
928
|
return null;
|
|
929
|
-
return { videoId, hash:
|
|
929
|
+
return { videoId, hash: extractVimeoHash2(src) || undefined };
|
|
930
930
|
}
|
|
931
931
|
if (typeof src === "object" && "type" in src && src.type === "vimeo") {
|
|
932
932
|
const vSrc = src;
|
|
933
933
|
return {
|
|
934
|
-
videoId: vSrc.videoId ||
|
|
934
|
+
videoId: vSrc.videoId || extractVimeoId2(vSrc.src) || "",
|
|
935
935
|
hash: vSrc.hash
|
|
936
936
|
};
|
|
937
937
|
}
|
|
@@ -939,7 +939,7 @@ function parseVimeoSource(src) {
|
|
|
939
939
|
}
|
|
940
940
|
var VIMEO_SDK_URL = "https://player.vimeo.com/api/player.js";
|
|
941
941
|
|
|
942
|
-
class
|
|
942
|
+
class VimeoProvider2 extends BaseProvider2 {
|
|
943
943
|
name = "vimeo";
|
|
944
944
|
type = "vimeo";
|
|
945
945
|
container_el = null;
|
|
@@ -994,7 +994,7 @@ class VimeoProvider extends BaseProvider {
|
|
|
994
994
|
this.container_el = null;
|
|
995
995
|
}
|
|
996
996
|
canPlay(src) {
|
|
997
|
-
return
|
|
997
|
+
return isVimeoSource2(src);
|
|
998
998
|
}
|
|
999
999
|
async load(src) {
|
|
1000
1000
|
const parsed = parseVimeoSource(src);
|
|
@@ -1185,11 +1185,11 @@ class VimeoProvider extends BaseProvider {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
|
-
var
|
|
1188
|
+
var vimeoLoader2 = {
|
|
1189
1189
|
name: "vimeo",
|
|
1190
1190
|
type: "vimeo",
|
|
1191
1191
|
canPlay(src) {
|
|
1192
|
-
return
|
|
1192
|
+
return isVimeoSource2(src);
|
|
1193
1193
|
},
|
|
1194
1194
|
mediaType() {
|
|
1195
1195
|
return "video";
|
|
@@ -1198,13 +1198,13 @@ var vimeoLoader = {
|
|
|
1198
1198
|
return ["https://player.vimeo.com", "https://i.vimeocdn.com", "https://f.vimeocdn.com"];
|
|
1199
1199
|
},
|
|
1200
1200
|
async load(container, options) {
|
|
1201
|
-
const provider = new
|
|
1201
|
+
const provider = new VimeoProvider2;
|
|
1202
1202
|
await provider.setup(container, options);
|
|
1203
1203
|
return provider;
|
|
1204
1204
|
}
|
|
1205
1205
|
};
|
|
1206
1206
|
// src/providers/hls.ts
|
|
1207
|
-
function
|
|
1207
|
+
function isHLSSource2(src) {
|
|
1208
1208
|
if (typeof src === "string") {
|
|
1209
1209
|
const url = src.toLowerCase();
|
|
1210
1210
|
return url.endsWith(".m3u8") || url.includes("application/x-mpegurl") || url.includes("application/vnd.apple.mpegurl");
|
|
@@ -1215,13 +1215,13 @@ function isHLSSource(src) {
|
|
|
1215
1215
|
}
|
|
1216
1216
|
return false;
|
|
1217
1217
|
}
|
|
1218
|
-
function
|
|
1218
|
+
function isNativeHLSSupported2() {
|
|
1219
1219
|
const video = document.createElement("video");
|
|
1220
1220
|
return video.canPlayType("application/vnd.apple.mpegurl") !== "";
|
|
1221
1221
|
}
|
|
1222
1222
|
var HLS_CDN_DEFAULT = "https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js";
|
|
1223
1223
|
|
|
1224
|
-
class
|
|
1224
|
+
class HLSProvider2 extends BaseProvider2 {
|
|
1225
1225
|
name = "hls";
|
|
1226
1226
|
type = "hls";
|
|
1227
1227
|
video = null;
|
|
@@ -1266,14 +1266,14 @@ class HLSProvider extends BaseProvider {
|
|
|
1266
1266
|
if (this.options.volume !== undefined)
|
|
1267
1267
|
this.video.volume = this.options.volume;
|
|
1268
1268
|
this.container.appendChild(this.video);
|
|
1269
|
-
this.eventsNormalizer = new
|
|
1270
|
-
this.cleanupFullscreen =
|
|
1269
|
+
this.eventsNormalizer = new MediaEventsNormalizer2(this.video, this.events);
|
|
1270
|
+
this.cleanupFullscreen = onFullscreenChange2((fullscreen) => {
|
|
1271
1271
|
this.events.emit("fullscreenchange", fullscreen);
|
|
1272
1272
|
});
|
|
1273
|
-
this.cleanupPiP =
|
|
1273
|
+
this.cleanupPiP = onPiPChange2(this.video, (pip) => {
|
|
1274
1274
|
this.events.emit("pipchange", pip);
|
|
1275
1275
|
});
|
|
1276
|
-
this.useNativeHLS =
|
|
1276
|
+
this.useNativeHLS = isNativeHLSSupported2();
|
|
1277
1277
|
if (!this.useNativeHLS) {
|
|
1278
1278
|
await this.loadHLSLibrary();
|
|
1279
1279
|
}
|
|
@@ -1328,7 +1328,7 @@ class HLSProvider extends BaseProvider {
|
|
|
1328
1328
|
this._textTracks = [];
|
|
1329
1329
|
}
|
|
1330
1330
|
canPlay(src) {
|
|
1331
|
-
return
|
|
1331
|
+
return isHLSSource2(src);
|
|
1332
1332
|
}
|
|
1333
1333
|
async load(src) {
|
|
1334
1334
|
if (!this.video)
|
|
@@ -1549,11 +1549,11 @@ class HLSProvider extends BaseProvider {
|
|
|
1549
1549
|
this.events.emit("texttrackchange", current || null);
|
|
1550
1550
|
}
|
|
1551
1551
|
}
|
|
1552
|
-
var
|
|
1552
|
+
var hlsLoader2 = {
|
|
1553
1553
|
name: "hls",
|
|
1554
1554
|
type: "hls",
|
|
1555
1555
|
canPlay(src) {
|
|
1556
|
-
return
|
|
1556
|
+
return isHLSSource2(src);
|
|
1557
1557
|
},
|
|
1558
1558
|
mediaType() {
|
|
1559
1559
|
return "video";
|
|
@@ -1562,7 +1562,7 @@ var hlsLoader = {
|
|
|
1562
1562
|
return ["https://cdn.jsdelivr.net"];
|
|
1563
1563
|
},
|
|
1564
1564
|
async load(container, options) {
|
|
1565
|
-
const provider = new
|
|
1565
|
+
const provider = new HLSProvider2;
|
|
1566
1566
|
await provider.setup(container, options);
|
|
1567
1567
|
return provider;
|
|
1568
1568
|
}
|
|
@@ -1596,7 +1596,7 @@ async function loadDashJS(cdnUrl) {
|
|
|
1596
1596
|
});
|
|
1597
1597
|
return dashLoading;
|
|
1598
1598
|
}
|
|
1599
|
-
function
|
|
1599
|
+
function isDASHSource2(src) {
|
|
1600
1600
|
if (typeof src === "object" && "type" in src && src.type === "dash") {
|
|
1601
1601
|
return true;
|
|
1602
1602
|
}
|
|
@@ -1606,7 +1606,7 @@ function isDASHSource(src) {
|
|
|
1606
1606
|
return false;
|
|
1607
1607
|
}
|
|
1608
1608
|
|
|
1609
|
-
class
|
|
1609
|
+
class DASHProvider2 extends BaseProvider2 {
|
|
1610
1610
|
name = "dash";
|
|
1611
1611
|
type = "dash";
|
|
1612
1612
|
dash = null;
|
|
@@ -1739,7 +1739,7 @@ class DASHProvider extends BaseProvider {
|
|
|
1739
1739
|
return;
|
|
1740
1740
|
if (typeof src === "string") {
|
|
1741
1741
|
this.source = { src, type: "dash" };
|
|
1742
|
-
} else if (
|
|
1742
|
+
} else if (isDASHSource2(src)) {
|
|
1743
1743
|
this.source = src;
|
|
1744
1744
|
} else {
|
|
1745
1745
|
this.emitError(4, "Invalid DASH source");
|
|
@@ -1751,7 +1751,7 @@ class DASHProvider extends BaseProvider {
|
|
|
1751
1751
|
this.dash.initialize(this.video, this.source.src, false);
|
|
1752
1752
|
}
|
|
1753
1753
|
canPlay(src) {
|
|
1754
|
-
return
|
|
1754
|
+
return isDASHSource2(src);
|
|
1755
1755
|
}
|
|
1756
1756
|
cleanup() {
|
|
1757
1757
|
if (this.dash) {
|
|
@@ -1928,17 +1928,17 @@ class DASHProvider extends BaseProvider {
|
|
|
1928
1928
|
}
|
|
1929
1929
|
}
|
|
1930
1930
|
}
|
|
1931
|
-
var
|
|
1931
|
+
var dashLoader2 = {
|
|
1932
1932
|
name: "dash",
|
|
1933
1933
|
type: "dash",
|
|
1934
1934
|
canPlay(src) {
|
|
1935
|
-
return
|
|
1935
|
+
return isDASHSource2(src);
|
|
1936
1936
|
},
|
|
1937
1937
|
mediaType() {
|
|
1938
1938
|
return "video";
|
|
1939
1939
|
},
|
|
1940
1940
|
async load(container, options) {
|
|
1941
|
-
const provider = new
|
|
1941
|
+
const provider = new DASHProvider2;
|
|
1942
1942
|
await provider.setup(container, options);
|
|
1943
1943
|
return provider;
|
|
1944
1944
|
},
|
|
@@ -1947,45 +1947,69 @@ var dashLoader = {
|
|
|
1947
1947
|
}
|
|
1948
1948
|
};
|
|
1949
1949
|
// src/providers/index.ts
|
|
1950
|
-
var
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1950
|
+
var defaultLoaders2 = [
|
|
1951
|
+
hlsLoader2,
|
|
1952
|
+
dashLoader2,
|
|
1953
|
+
youtubeLoader2,
|
|
1954
|
+
vimeoLoader2,
|
|
1955
|
+
html5Loader2
|
|
1956
1956
|
];
|
|
1957
|
-
function
|
|
1957
|
+
function untypedUrl(src) {
|
|
1958
|
+
if (!src || typeof src !== "object" || typeof src.src !== "string")
|
|
1959
|
+
return null;
|
|
1960
|
+
return "type" in src && src.type ? null : src.src;
|
|
1961
|
+
}
|
|
1962
|
+
var TYPE_FOR_LOADER = {
|
|
1963
|
+
youtube: () => "youtube",
|
|
1964
|
+
vimeo: () => "vimeo",
|
|
1965
|
+
hls: () => "application/x-mpegurl",
|
|
1966
|
+
dash: () => "dash",
|
|
1967
|
+
video: (url) => getMimeType(url)
|
|
1968
|
+
};
|
|
1969
|
+
function withType(src, loader) {
|
|
1970
|
+
const url = untypedUrl(src);
|
|
1971
|
+
const type = url && TYPE_FOR_LOADER[loader.type];
|
|
1972
|
+
return url && type ? { ...src, type: type(url) } : src;
|
|
1973
|
+
}
|
|
1974
|
+
function findLoader2(src, loaders = defaultLoaders2) {
|
|
1958
1975
|
for (const loader of loaders) {
|
|
1959
1976
|
if (loader.canPlay(src)) {
|
|
1960
1977
|
return loader;
|
|
1961
1978
|
}
|
|
1962
1979
|
}
|
|
1980
|
+
const url = untypedUrl(src);
|
|
1981
|
+
if (url) {
|
|
1982
|
+
for (const loader of loaders) {
|
|
1983
|
+
if (loader.canPlay(url))
|
|
1984
|
+
return loader;
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1963
1987
|
return null;
|
|
1964
1988
|
}
|
|
1965
|
-
function findSourceCandidates(sources, loaders =
|
|
1989
|
+
function findSourceCandidates(sources, loaders = defaultLoaders2) {
|
|
1966
1990
|
const candidates = [];
|
|
1967
1991
|
sources.forEach((src, index) => {
|
|
1968
|
-
const loader =
|
|
1992
|
+
const loader = findLoader2(src, loaders);
|
|
1969
1993
|
if (loader)
|
|
1970
|
-
candidates.push({ src, index, loader });
|
|
1994
|
+
candidates.push({ src: withType(src, loader), index, loader });
|
|
1971
1995
|
});
|
|
1972
1996
|
return candidates;
|
|
1973
1997
|
}
|
|
1974
|
-
function
|
|
1975
|
-
const loader =
|
|
1998
|
+
function detectMediaType2(src, loaders = defaultLoaders2) {
|
|
1999
|
+
const loader = findLoader2(src, loaders);
|
|
1976
2000
|
return loader?.mediaType(src) || "unknown";
|
|
1977
2001
|
}
|
|
1978
|
-
function
|
|
1979
|
-
const loader =
|
|
2002
|
+
function getPreconnectHints2(src, loaders = defaultLoaders2) {
|
|
2003
|
+
const loader = findLoader2(src, loaders);
|
|
1980
2004
|
return loader?.preconnect?.() || [];
|
|
1981
2005
|
}
|
|
1982
2006
|
|
|
1983
2007
|
// src/player.ts
|
|
1984
|
-
class
|
|
2008
|
+
class Player2 {
|
|
1985
2009
|
_el;
|
|
1986
2010
|
_options;
|
|
1987
2011
|
_store;
|
|
1988
|
-
_events = new
|
|
2012
|
+
_events = new EventEmitter2;
|
|
1989
2013
|
_provider = null;
|
|
1990
2014
|
_loaders;
|
|
1991
2015
|
_cleanupFns = [];
|
|
@@ -2002,8 +2026,8 @@ class Player {
|
|
|
2002
2026
|
this._el = container;
|
|
2003
2027
|
}
|
|
2004
2028
|
this._options = { ...defaultOptions, ...options };
|
|
2005
|
-
this._loaders =
|
|
2006
|
-
this._store = new
|
|
2029
|
+
this._loaders = defaultLoaders2;
|
|
2030
|
+
this._store = new StateStore2;
|
|
2007
2031
|
this.setupElement();
|
|
2008
2032
|
this.setupState();
|
|
2009
2033
|
this.setupKeyboard();
|
|
@@ -2088,7 +2112,7 @@ class Player {
|
|
|
2088
2112
|
seekPercent: (percent) => this.seekTo(percent / 100 * this.state.duration)
|
|
2089
2113
|
};
|
|
2090
2114
|
const config = typeof this._options.keyboard === "object" ? this._options.keyboard : {};
|
|
2091
|
-
const handler =
|
|
2115
|
+
const handler = createKeyboardHandler2(actions, {
|
|
2092
2116
|
seekStep: config.seekStep,
|
|
2093
2117
|
volumeStep: config.volumeStep
|
|
2094
2118
|
});
|
|
@@ -2097,7 +2121,7 @@ class Player {
|
|
|
2097
2121
|
this._cleanupFns.push(() => target.removeEventListener("keydown", handler));
|
|
2098
2122
|
}
|
|
2099
2123
|
setupActivity() {
|
|
2100
|
-
const cleanup =
|
|
2124
|
+
const cleanup = createActivityDetector2(this._el, {
|
|
2101
2125
|
timeout: this._options.controlsTimeout || 3000,
|
|
2102
2126
|
onActive: () => {
|
|
2103
2127
|
this._store.batch({ userActive: true, controlsVisible: true });
|
|
@@ -2124,14 +2148,14 @@ class Player {
|
|
|
2124
2148
|
return;
|
|
2125
2149
|
const config = typeof this._options.storage === "object" ? this._options.storage : {};
|
|
2126
2150
|
const storage = config.type === "session" ? sessionStorage : localStorage;
|
|
2127
|
-
const cleanup =
|
|
2151
|
+
const cleanup = createStorageSync2(this._store, config.persist || ["volume", "muted", "playbackRate"], storage);
|
|
2128
2152
|
this._cleanupFns.push(cleanup);
|
|
2129
2153
|
}
|
|
2130
2154
|
setupMediaSession() {
|
|
2131
2155
|
if (this._options.mediaSession === false)
|
|
2132
2156
|
return;
|
|
2133
2157
|
const sessionOpts = typeof this._options.mediaSession === "object" ? this._options.mediaSession : this._options.title ? { title: this._options.title } : undefined;
|
|
2134
|
-
const cleanup =
|
|
2158
|
+
const cleanup = createMediaSession2(this._store, {
|
|
2135
2159
|
play: () => this.play(),
|
|
2136
2160
|
pause: () => this.pause(),
|
|
2137
2161
|
seekTo: (time) => this.seekTo(time),
|
|
@@ -2353,7 +2377,7 @@ class Player {
|
|
|
2353
2377
|
provider.on("progress", (buffered) => {
|
|
2354
2378
|
this._store.batch({
|
|
2355
2379
|
buffered,
|
|
2356
|
-
bufferedAmount:
|
|
2380
|
+
bufferedAmount: selectBufferedAmount2({ ...this.state, buffered })
|
|
2357
2381
|
});
|
|
2358
2382
|
this._events.emit("progress", buffered);
|
|
2359
2383
|
});
|
|
@@ -2451,13 +2475,13 @@ class Player {
|
|
|
2451
2475
|
}
|
|
2452
2476
|
await this._provider?.enterFullscreen();
|
|
2453
2477
|
if (this._options.fullscreenOrientationLock !== false) {
|
|
2454
|
-
|
|
2478
|
+
lockOrientation2("landscape");
|
|
2455
2479
|
}
|
|
2456
2480
|
}
|
|
2457
2481
|
async exitFullscreen() {
|
|
2458
2482
|
await this._provider?.exitFullscreen();
|
|
2459
2483
|
if (this._options.fullscreenOrientationLock !== false) {
|
|
2460
|
-
|
|
2484
|
+
unlockOrientation2();
|
|
2461
2485
|
}
|
|
2462
2486
|
}
|
|
2463
2487
|
async toggleFullscreen() {
|
|
@@ -2539,10 +2563,10 @@ var defaultOptions = {
|
|
|
2539
2563
|
controlsTimeout: 3000,
|
|
2540
2564
|
storage: true
|
|
2541
2565
|
};
|
|
2542
|
-
function
|
|
2543
|
-
return new
|
|
2566
|
+
function createPlayer2(container, options) {
|
|
2567
|
+
return new Player2(container, options);
|
|
2544
2568
|
}
|
|
2545
|
-
function
|
|
2569
|
+
function getPlayer2(element) {
|
|
2546
2570
|
return element.__videoPlayer || null;
|
|
2547
2571
|
}
|
|
2548
2572
|
|
|
@@ -2553,7 +2577,7 @@ var HTMLElementBase = globalThis.HTMLElement ?? class {
|
|
|
2553
2577
|
// src/elements/video-player.ts
|
|
2554
2578
|
var OBSERVED_ATTRS = ["src", "poster", "autoplay", "loop", "muted", "controls", "volume", "playback-rate", "preload", "playsinline", "crossorigin", "controlslist", "disable-picture-in-picture"];
|
|
2555
2579
|
|
|
2556
|
-
class
|
|
2580
|
+
class VideoPlayerElement2 extends HTMLElementBase {
|
|
2557
2581
|
_player = null;
|
|
2558
2582
|
_container = null;
|
|
2559
2583
|
_disconnectId = 0;
|
|
@@ -2575,7 +2599,7 @@ class VideoPlayerElement extends HTMLElementBase {
|
|
|
2575
2599
|
this._container.appendChild(slot);
|
|
2576
2600
|
shadow.appendChild(this._container);
|
|
2577
2601
|
const options = this.buildOptions();
|
|
2578
|
-
this._player = new
|
|
2602
|
+
this._player = new Player2(this._container, options);
|
|
2579
2603
|
this.forwardEvents();
|
|
2580
2604
|
}
|
|
2581
2605
|
disconnectedCallback() {
|
|
@@ -2717,7 +2741,7 @@ class VideoPlayerElement extends HTMLElementBase {
|
|
|
2717
2741
|
}
|
|
2718
2742
|
}
|
|
2719
2743
|
// src/elements/utils.ts
|
|
2720
|
-
function
|
|
2744
|
+
function formatTime2(seconds, guide = 0) {
|
|
2721
2745
|
if (!isFinite(seconds) || isNaN(seconds))
|
|
2722
2746
|
return "0:00";
|
|
2723
2747
|
const s = Math.floor(seconds);
|
|
@@ -2730,7 +2754,7 @@ function formatTime(seconds, guide = 0) {
|
|
|
2730
2754
|
}
|
|
2731
2755
|
return `${m}:${sec.toString().padStart(2, "0")}`;
|
|
2732
2756
|
}
|
|
2733
|
-
function
|
|
2757
|
+
function formatTimePhrase2(seconds) {
|
|
2734
2758
|
if (!isFinite(seconds) || isNaN(seconds))
|
|
2735
2759
|
return "0 seconds";
|
|
2736
2760
|
const s = Math.floor(seconds);
|
|
@@ -2746,7 +2770,7 @@ function formatTimePhrase(seconds) {
|
|
|
2746
2770
|
parts.push(`${sec} ${sec === 1 ? "second" : "seconds"}`);
|
|
2747
2771
|
return parts.join(", ");
|
|
2748
2772
|
}
|
|
2749
|
-
function
|
|
2773
|
+
function toISODuration2(seconds) {
|
|
2750
2774
|
if (!isFinite(seconds) || isNaN(seconds))
|
|
2751
2775
|
return "PT0S";
|
|
2752
2776
|
const s = Math.floor(seconds);
|
|
@@ -2762,7 +2786,7 @@ function toISODuration(seconds) {
|
|
|
2762
2786
|
result += `${sec}S`;
|
|
2763
2787
|
return result;
|
|
2764
2788
|
}
|
|
2765
|
-
function
|
|
2789
|
+
function resolvePlayer2(el) {
|
|
2766
2790
|
const forId = el.getAttribute("for");
|
|
2767
2791
|
if (forId) {
|
|
2768
2792
|
const target = document.getElementById(forId);
|
|
@@ -2773,7 +2797,7 @@ function resolvePlayer(el) {
|
|
|
2773
2797
|
}
|
|
2774
2798
|
|
|
2775
2799
|
// src/elements/video-skin.ts
|
|
2776
|
-
class
|
|
2800
|
+
class VideoSkin2 extends HTMLElementBase {
|
|
2777
2801
|
_cleanups = [];
|
|
2778
2802
|
connectedCallback() {
|
|
2779
2803
|
if (!this.shadowRoot) {
|
|
@@ -2846,7 +2870,7 @@ class VideoSkin extends HTMLElementBase {
|
|
|
2846
2870
|
this._cleanups = [];
|
|
2847
2871
|
}
|
|
2848
2872
|
attach() {
|
|
2849
|
-
const player =
|
|
2873
|
+
const player = resolvePlayer2(this);
|
|
2850
2874
|
if (!player)
|
|
2851
2875
|
return;
|
|
2852
2876
|
const unsub = player.subscribe((state) => {
|
|
@@ -2871,7 +2895,7 @@ class VideoSkin extends HTMLElementBase {
|
|
|
2871
2895
|
var PLAY_ICON = "M8 5v14l11-7z";
|
|
2872
2896
|
var PAUSE_ICON = "M6 19h4V5H6v14zm8-14v14h4V5h-4z";
|
|
2873
2897
|
|
|
2874
|
-
class
|
|
2898
|
+
class MediaPlayButton2 extends HTMLElementBase {
|
|
2875
2899
|
_cleanup = null;
|
|
2876
2900
|
_onClick = null;
|
|
2877
2901
|
connectedCallback() {
|
|
@@ -2905,7 +2929,7 @@ class MediaPlayButton extends HTMLElementBase {
|
|
|
2905
2929
|
this._onClick = null;
|
|
2906
2930
|
}
|
|
2907
2931
|
attach() {
|
|
2908
|
-
const player =
|
|
2932
|
+
const player = resolvePlayer2(this);
|
|
2909
2933
|
if (!player)
|
|
2910
2934
|
return;
|
|
2911
2935
|
const btn = this.shadowRoot.querySelector("button");
|
|
@@ -2933,7 +2957,7 @@ function getVolumeIcon(muted, volume) {
|
|
|
2933
2957
|
return ICON_HIGH;
|
|
2934
2958
|
}
|
|
2935
2959
|
|
|
2936
|
-
class
|
|
2960
|
+
class MediaMuteButton2 extends HTMLElementBase {
|
|
2937
2961
|
_cleanup = null;
|
|
2938
2962
|
connectedCallback() {
|
|
2939
2963
|
if (!this.shadowRoot) {
|
|
@@ -2962,7 +2986,7 @@ class MediaMuteButton extends HTMLElementBase {
|
|
|
2962
2986
|
this._cleanup = null;
|
|
2963
2987
|
}
|
|
2964
2988
|
attach() {
|
|
2965
|
-
const player =
|
|
2989
|
+
const player = resolvePlayer2(this);
|
|
2966
2990
|
if (!player)
|
|
2967
2991
|
return;
|
|
2968
2992
|
const btn = this.shadowRoot.querySelector("button");
|
|
@@ -2980,7 +3004,7 @@ class MediaMuteButton extends HTMLElementBase {
|
|
|
2980
3004
|
var ENTER_FS = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z";
|
|
2981
3005
|
var EXIT_FS = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z";
|
|
2982
3006
|
|
|
2983
|
-
class
|
|
3007
|
+
class MediaFullscreenButton2 extends HTMLElementBase {
|
|
2984
3008
|
_cleanup = null;
|
|
2985
3009
|
connectedCallback() {
|
|
2986
3010
|
if (!this.shadowRoot) {
|
|
@@ -3011,7 +3035,7 @@ class MediaFullscreenButton extends HTMLElementBase {
|
|
|
3011
3035
|
this._cleanup = null;
|
|
3012
3036
|
}
|
|
3013
3037
|
attach() {
|
|
3014
|
-
const player =
|
|
3038
|
+
const player = resolvePlayer2(this);
|
|
3015
3039
|
if (!player)
|
|
3016
3040
|
return;
|
|
3017
3041
|
const btn = this.shadowRoot.querySelector("button");
|
|
@@ -3035,7 +3059,7 @@ class MediaFullscreenButton extends HTMLElementBase {
|
|
|
3035
3059
|
// src/elements/media-pip-button.ts
|
|
3036
3060
|
var PIP_ICON = "M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z";
|
|
3037
3061
|
|
|
3038
|
-
class
|
|
3062
|
+
class MediaPipButton2 extends HTMLElementBase {
|
|
3039
3063
|
_cleanup = null;
|
|
3040
3064
|
connectedCallback() {
|
|
3041
3065
|
if (!this.shadowRoot) {
|
|
@@ -3066,7 +3090,7 @@ class MediaPipButton extends HTMLElementBase {
|
|
|
3066
3090
|
this._cleanup = null;
|
|
3067
3091
|
}
|
|
3068
3092
|
attach() {
|
|
3069
|
-
const player =
|
|
3093
|
+
const player = resolvePlayer2(this);
|
|
3070
3094
|
if (!player)
|
|
3071
3095
|
return;
|
|
3072
3096
|
const btn = this.shadowRoot.querySelector("button");
|
|
@@ -3084,7 +3108,7 @@ class MediaPipButton extends HTMLElementBase {
|
|
|
3084
3108
|
}
|
|
3085
3109
|
}
|
|
3086
3110
|
// src/elements/media-time-display.ts
|
|
3087
|
-
class
|
|
3111
|
+
class MediaTimeDisplay2 extends HTMLElementBase {
|
|
3088
3112
|
_cleanup = null;
|
|
3089
3113
|
_showRemaining = false;
|
|
3090
3114
|
static get observedAttributes() {
|
|
@@ -3123,13 +3147,13 @@ class MediaTimeDisplay extends HTMLElementBase {
|
|
|
3123
3147
|
handleClick = () => {
|
|
3124
3148
|
if (this.type === "duration") {
|
|
3125
3149
|
this._showRemaining = !this._showRemaining;
|
|
3126
|
-
const player =
|
|
3150
|
+
const player = resolvePlayer2(this);
|
|
3127
3151
|
if (player)
|
|
3128
3152
|
this.render(player.state);
|
|
3129
3153
|
}
|
|
3130
3154
|
};
|
|
3131
3155
|
attach() {
|
|
3132
|
-
const player =
|
|
3156
|
+
const player = resolvePlayer2(this);
|
|
3133
3157
|
if (!player)
|
|
3134
3158
|
return;
|
|
3135
3159
|
const unsub = player.subscribe((state) => {
|
|
@@ -3145,21 +3169,21 @@ class MediaTimeDisplay extends HTMLElementBase {
|
|
|
3145
3169
|
let seconds;
|
|
3146
3170
|
if (type === "remaining" || type === "duration" && this._showRemaining) {
|
|
3147
3171
|
seconds = Math.max(state.duration - state.currentTime, 0);
|
|
3148
|
-
const formatted = `-${
|
|
3172
|
+
const formatted = `-${formatTime2(seconds, state.duration)}`;
|
|
3149
3173
|
timeEl.textContent = formatted;
|
|
3150
3174
|
} else if (type === "duration") {
|
|
3151
3175
|
seconds = state.duration;
|
|
3152
|
-
timeEl.textContent =
|
|
3176
|
+
timeEl.textContent = formatTime2(seconds);
|
|
3153
3177
|
} else {
|
|
3154
3178
|
seconds = state.currentTime;
|
|
3155
|
-
timeEl.textContent =
|
|
3179
|
+
timeEl.textContent = formatTime2(seconds, state.duration);
|
|
3156
3180
|
}
|
|
3157
|
-
timeEl.setAttribute("datetime",
|
|
3158
|
-
timeEl.setAttribute("aria-valuetext",
|
|
3181
|
+
timeEl.setAttribute("datetime", toISODuration2(seconds));
|
|
3182
|
+
timeEl.setAttribute("aria-valuetext", formatTimePhrase2(seconds));
|
|
3159
3183
|
}
|
|
3160
3184
|
}
|
|
3161
3185
|
// src/elements/media-time-group.ts
|
|
3162
|
-
class
|
|
3186
|
+
class MediaTimeGroup2 extends HTMLElementBase {
|
|
3163
3187
|
connectedCallback() {
|
|
3164
3188
|
if (!this.shadowRoot) {
|
|
3165
3189
|
const shadow = this.attachShadow({ mode: "open" });
|
|
@@ -3181,7 +3205,7 @@ class MediaTimeGroup extends HTMLElementBase {
|
|
|
3181
3205
|
}
|
|
3182
3206
|
}
|
|
3183
3207
|
// src/elements/media-time-separator.ts
|
|
3184
|
-
class
|
|
3208
|
+
class MediaTimeSeparator2 extends HTMLElementBase {
|
|
3185
3209
|
connectedCallback() {
|
|
3186
3210
|
if (!this.shadowRoot) {
|
|
3187
3211
|
const shadow = this.attachShadow({ mode: "open" });
|
|
@@ -3205,7 +3229,7 @@ class MediaTimeSeparator extends HTMLElementBase {
|
|
|
3205
3229
|
}
|
|
3206
3230
|
}
|
|
3207
3231
|
// src/elements/media-preview-time.ts
|
|
3208
|
-
class
|
|
3232
|
+
class MediaPreviewTime2 extends HTMLElementBase {
|
|
3209
3233
|
_cleanups = [];
|
|
3210
3234
|
connectedCallback() {
|
|
3211
3235
|
if (!this.shadowRoot) {
|
|
@@ -3231,7 +3255,7 @@ class MediaPreviewTime extends HTMLElementBase {
|
|
|
3231
3255
|
this._cleanups = [];
|
|
3232
3256
|
}
|
|
3233
3257
|
attach() {
|
|
3234
|
-
const player =
|
|
3258
|
+
const player = resolvePlayer2(this);
|
|
3235
3259
|
if (!player)
|
|
3236
3260
|
return;
|
|
3237
3261
|
const progressBar = this.closest("media-progress-bar") || this.parentElement?.querySelector("media-progress-bar");
|
|
@@ -3251,12 +3275,12 @@ class MediaPreviewTime extends HTMLElementBase {
|
|
|
3251
3275
|
updateTime(time, duration) {
|
|
3252
3276
|
const span = this.shadowRoot?.querySelector("span");
|
|
3253
3277
|
if (span) {
|
|
3254
|
-
span.textContent =
|
|
3278
|
+
span.textContent = formatTime2(time, duration);
|
|
3255
3279
|
}
|
|
3256
3280
|
}
|
|
3257
3281
|
}
|
|
3258
3282
|
// src/elements/media-progress-bar.ts
|
|
3259
|
-
class
|
|
3283
|
+
class MediaProgressBar2 extends HTMLElementBase {
|
|
3260
3284
|
_cleanups = [];
|
|
3261
3285
|
_isDragging = false;
|
|
3262
3286
|
connectedCallback() {
|
|
@@ -3331,7 +3355,7 @@ class MediaProgressBar extends HTMLElementBase {
|
|
|
3331
3355
|
this._cleanups = [];
|
|
3332
3356
|
}
|
|
3333
3357
|
attach() {
|
|
3334
|
-
const player =
|
|
3358
|
+
const player = resolvePlayer2(this);
|
|
3335
3359
|
if (!player)
|
|
3336
3360
|
return;
|
|
3337
3361
|
const container = this.shadowRoot.querySelector(".container");
|
|
@@ -3352,7 +3376,7 @@ class MediaProgressBar extends HTMLElementBase {
|
|
|
3352
3376
|
const rect = track.getBoundingClientRect();
|
|
3353
3377
|
const percent = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
3354
3378
|
const time = percent * (player.state.duration || 0);
|
|
3355
|
-
tooltip.textContent =
|
|
3379
|
+
tooltip.textContent = formatTime2(time, player.state.duration);
|
|
3356
3380
|
const containerRect = container.getBoundingClientRect();
|
|
3357
3381
|
const tooltipWidth = tooltip.offsetWidth;
|
|
3358
3382
|
const rawLeft = e.clientX - containerRect.left;
|
|
@@ -3419,7 +3443,7 @@ class MediaProgressBar extends HTMLElementBase {
|
|
|
3419
3443
|
fill.style.width = `${percent}%`;
|
|
3420
3444
|
thumb.style.left = `${percent}%`;
|
|
3421
3445
|
container.setAttribute("aria-valuenow", String(Math.round(percent)));
|
|
3422
|
-
container.setAttribute("aria-valuetext", `${
|
|
3446
|
+
container.setAttribute("aria-valuetext", `${formatTimePhrase2(state.currentTime)} of ${formatTimePhrase2(duration)}`);
|
|
3423
3447
|
const bufferedPct = (state.bufferedAmount || 0) * 100;
|
|
3424
3448
|
buffered.style.width = `${bufferedPct}%`;
|
|
3425
3449
|
});
|
|
@@ -3427,7 +3451,7 @@ class MediaProgressBar extends HTMLElementBase {
|
|
|
3427
3451
|
}
|
|
3428
3452
|
}
|
|
3429
3453
|
// src/elements/media-volume-slider.ts
|
|
3430
|
-
class
|
|
3454
|
+
class MediaVolumeSlider2 extends HTMLElementBase {
|
|
3431
3455
|
_cleanups = [];
|
|
3432
3456
|
_isDragging = false;
|
|
3433
3457
|
connectedCallback() {
|
|
@@ -3476,7 +3500,7 @@ class MediaVolumeSlider extends HTMLElementBase {
|
|
|
3476
3500
|
this._cleanups = [];
|
|
3477
3501
|
}
|
|
3478
3502
|
attach() {
|
|
3479
|
-
const player =
|
|
3503
|
+
const player = resolvePlayer2(this);
|
|
3480
3504
|
if (!player)
|
|
3481
3505
|
return;
|
|
3482
3506
|
const container = this.shadowRoot.querySelector(".container");
|
|
@@ -3545,7 +3569,7 @@ class MediaVolumeSlider extends HTMLElementBase {
|
|
|
3545
3569
|
}
|
|
3546
3570
|
}
|
|
3547
3571
|
// src/core/popover.ts
|
|
3548
|
-
function
|
|
3572
|
+
function computePosition2(anchor, popover, options = {}) {
|
|
3549
3573
|
const {
|
|
3550
3574
|
placement = "top",
|
|
3551
3575
|
offset = 4,
|
|
@@ -3595,11 +3619,11 @@ function computePosition(anchor, popover, options = {}) {
|
|
|
3595
3619
|
const finalPlacement = `${vertical}${align}`;
|
|
3596
3620
|
return { top, left, placement: finalPlacement };
|
|
3597
3621
|
}
|
|
3598
|
-
function
|
|
3622
|
+
function applyPosition2(anchor, popover, options = {}) {
|
|
3599
3623
|
const prevVisibility = popover.style.visibility;
|
|
3600
3624
|
popover.style.visibility = "hidden";
|
|
3601
3625
|
popover.style.display = "block";
|
|
3602
|
-
const result =
|
|
3626
|
+
const result = computePosition2(anchor, popover, options);
|
|
3603
3627
|
const offsetParent = popover.offsetParent;
|
|
3604
3628
|
if (offsetParent) {
|
|
3605
3629
|
const parentRect = offsetParent.getBoundingClientRect();
|
|
@@ -3617,7 +3641,7 @@ function applyPosition(anchor, popover, options = {}) {
|
|
|
3617
3641
|
var GEAR_ICON = "M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z";
|
|
3618
3642
|
var SPEEDS = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
|
|
3619
3643
|
|
|
3620
|
-
class
|
|
3644
|
+
class MediaSettingsMenu2 extends HTMLElementBase {
|
|
3621
3645
|
_cleanup = null;
|
|
3622
3646
|
_isOpen = false;
|
|
3623
3647
|
_currentPanel = "main";
|
|
@@ -3720,7 +3744,7 @@ class MediaSettingsMenu extends HTMLElementBase {
|
|
|
3720
3744
|
if (!trigger || !menu)
|
|
3721
3745
|
return;
|
|
3722
3746
|
const playerEl = this.closest("video-player, .ts-video-player");
|
|
3723
|
-
const result =
|
|
3747
|
+
const result = computePosition2(trigger, menu, {
|
|
3724
3748
|
placement: "top-end",
|
|
3725
3749
|
offset: 4,
|
|
3726
3750
|
boundary: playerEl,
|
|
@@ -3730,7 +3754,7 @@ class MediaSettingsMenu extends HTMLElementBase {
|
|
|
3730
3754
|
menu.style.left = `${result.left}px`;
|
|
3731
3755
|
}
|
|
3732
3756
|
attach() {
|
|
3733
|
-
const player =
|
|
3757
|
+
const player = resolvePlayer2(this);
|
|
3734
3758
|
if (!player)
|
|
3735
3759
|
return;
|
|
3736
3760
|
const unsub = player.subscribe(() => {
|
|
@@ -3740,7 +3764,7 @@ class MediaSettingsMenu extends HTMLElementBase {
|
|
|
3740
3764
|
this._cleanup = unsub;
|
|
3741
3765
|
}
|
|
3742
3766
|
renderPanel() {
|
|
3743
|
-
const player =
|
|
3767
|
+
const player = resolvePlayer2(this);
|
|
3744
3768
|
if (!player)
|
|
3745
3769
|
return;
|
|
3746
3770
|
const menu = this.shadowRoot.querySelector(".menu");
|
|
@@ -3870,7 +3894,7 @@ class MediaSettingsMenu extends HTMLElementBase {
|
|
|
3870
3894
|
}
|
|
3871
3895
|
}
|
|
3872
3896
|
// src/elements/media-seek-button.ts
|
|
3873
|
-
class
|
|
3897
|
+
class MediaSeekButton2 extends HTMLElementBase {
|
|
3874
3898
|
cleanup = null;
|
|
3875
3899
|
onClick = null;
|
|
3876
3900
|
connectedCallback() {
|
|
@@ -3898,7 +3922,7 @@ class MediaSeekButton extends HTMLElementBase {
|
|
|
3898
3922
|
this.onClick = null;
|
|
3899
3923
|
}
|
|
3900
3924
|
attach() {
|
|
3901
|
-
const player =
|
|
3925
|
+
const player = resolvePlayer2(this);
|
|
3902
3926
|
const button = this.shadowRoot?.querySelector("button");
|
|
3903
3927
|
if (!player || !button)
|
|
3904
3928
|
return;
|
|
@@ -3917,7 +3941,7 @@ class MediaSeekButton extends HTMLElementBase {
|
|
|
3917
3941
|
// src/elements/media-playback-rate-button.ts
|
|
3918
3942
|
var defaultRates = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
3919
3943
|
|
|
3920
|
-
class
|
|
3944
|
+
class MediaPlaybackRateButton2 extends HTMLElementBase {
|
|
3921
3945
|
cleanup = null;
|
|
3922
3946
|
onClick = null;
|
|
3923
3947
|
connectedCallback() {
|
|
@@ -3948,7 +3972,7 @@ class MediaPlaybackRateButton extends HTMLElementBase {
|
|
|
3948
3972
|
return [...new Set(rates.length > 0 ? rates : defaultRates)].sort((a, b) => a - b);
|
|
3949
3973
|
}
|
|
3950
3974
|
attach() {
|
|
3951
|
-
const player =
|
|
3975
|
+
const player = resolvePlayer2(this);
|
|
3952
3976
|
const button = this.shadowRoot?.querySelector("button");
|
|
3953
3977
|
if (!player || !button)
|
|
3954
3978
|
return;
|
|
@@ -3967,7 +3991,7 @@ class MediaPlaybackRateButton extends HTMLElementBase {
|
|
|
3967
3991
|
// src/elements/media-airplay-button.ts
|
|
3968
3992
|
var AIRPLAY_ICON = "M6.2 19h11.6L12 13.2 6.2 19zM19 3H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h2v-2H5V5h14v10h-2v2h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z";
|
|
3969
3993
|
|
|
3970
|
-
class
|
|
3994
|
+
class MediaAirplayButton2 extends HTMLElementBase {
|
|
3971
3995
|
cleanup = null;
|
|
3972
3996
|
connectedCallback() {
|
|
3973
3997
|
if (!this.shadowRoot) {
|
|
@@ -3992,7 +4016,7 @@ class MediaAirplayButton extends HTMLElementBase {
|
|
|
3992
4016
|
this.cleanup = null;
|
|
3993
4017
|
}
|
|
3994
4018
|
attach() {
|
|
3995
|
-
const player =
|
|
4019
|
+
const player = resolvePlayer2(this);
|
|
3996
4020
|
const button = this.shadowRoot?.querySelector("button");
|
|
3997
4021
|
if (!player || !button)
|
|
3998
4022
|
return;
|
|
@@ -4026,7 +4050,7 @@ class MediaAirplayButton extends HTMLElementBase {
|
|
|
4026
4050
|
}
|
|
4027
4051
|
}
|
|
4028
4052
|
// src/elements/media-live-button.ts
|
|
4029
|
-
class
|
|
4053
|
+
class MediaLiveButton2 extends HTMLElementBase {
|
|
4030
4054
|
cleanup = null;
|
|
4031
4055
|
connectedCallback() {
|
|
4032
4056
|
if (!this.shadowRoot) {
|
|
@@ -4049,7 +4073,7 @@ class MediaLiveButton extends HTMLElementBase {
|
|
|
4049
4073
|
this.cleanup = null;
|
|
4050
4074
|
}
|
|
4051
4075
|
attach() {
|
|
4052
|
-
const player =
|
|
4076
|
+
const player = resolvePlayer2(this);
|
|
4053
4077
|
const button = this.shadowRoot?.querySelector("button");
|
|
4054
4078
|
if (!player || !button)
|
|
4055
4079
|
return;
|
|
@@ -4081,7 +4105,7 @@ class MediaLiveButton extends HTMLElementBase {
|
|
|
4081
4105
|
}
|
|
4082
4106
|
}
|
|
4083
4107
|
// src/elements/media-error-display.ts
|
|
4084
|
-
class
|
|
4108
|
+
class MediaErrorDisplay2 extends HTMLElementBase {
|
|
4085
4109
|
cleanup = null;
|
|
4086
4110
|
connectedCallback() {
|
|
4087
4111
|
if (!this.shadowRoot) {
|
|
@@ -4102,7 +4126,7 @@ class MediaErrorDisplay extends HTMLElementBase {
|
|
|
4102
4126
|
this.cleanup = null;
|
|
4103
4127
|
}
|
|
4104
4128
|
attach() {
|
|
4105
|
-
const player =
|
|
4129
|
+
const player = resolvePlayer2(this);
|
|
4106
4130
|
const message = this.shadowRoot?.querySelector("p");
|
|
4107
4131
|
if (!player || !message)
|
|
4108
4132
|
return;
|
|
@@ -4122,7 +4146,7 @@ class MediaErrorDisplay extends HTMLElementBase {
|
|
|
4122
4146
|
// src/elements/media-remote-playback-button.ts
|
|
4123
4147
|
var REMOTE_ICON = "M1 18v3h3a3 3 0 0 0-3-3zm0-4v2a5 5 0 0 1 5 5h2a7 7 0 0 0-7-7zm0-4v2c5 0 9 4 9 9h2c0-6.1-4.9-11-11-11zm18-7H5a2 2 0 0 0-2 2v3h2V5h14v10h-5v2h5a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z";
|
|
4124
4148
|
|
|
4125
|
-
class
|
|
4149
|
+
class MediaRemotePlaybackButton2 extends HTMLElementBase {
|
|
4126
4150
|
cleanup = null;
|
|
4127
4151
|
connectedCallback() {
|
|
4128
4152
|
if (!this.shadowRoot) {
|
|
@@ -4147,7 +4171,7 @@ class MediaRemotePlaybackButton extends HTMLElementBase {
|
|
|
4147
4171
|
this.cleanup = null;
|
|
4148
4172
|
}
|
|
4149
4173
|
attach() {
|
|
4150
|
-
const player =
|
|
4174
|
+
const player = resolvePlayer2(this);
|
|
4151
4175
|
const button = this.shadowRoot?.querySelector("button");
|
|
4152
4176
|
if (!player || !button)
|
|
4153
4177
|
return;
|
|
@@ -4210,27 +4234,27 @@ class MediaRemotePlaybackButton extends HTMLElementBase {
|
|
|
4210
4234
|
}
|
|
4211
4235
|
// src/elements/index.ts
|
|
4212
4236
|
var elements = [
|
|
4213
|
-
["video-player",
|
|
4214
|
-
["video-skin",
|
|
4215
|
-
["media-play-button",
|
|
4216
|
-
["media-mute-button",
|
|
4217
|
-
["media-fullscreen-button",
|
|
4218
|
-
["media-pip-button",
|
|
4219
|
-
["media-time-display",
|
|
4220
|
-
["media-time-group",
|
|
4221
|
-
["media-time-separator",
|
|
4222
|
-
["media-preview-time",
|
|
4223
|
-
["media-progress-bar",
|
|
4224
|
-
["media-volume-slider",
|
|
4225
|
-
["media-settings-menu",
|
|
4226
|
-
["media-seek-button",
|
|
4227
|
-
["media-playback-rate-button",
|
|
4228
|
-
["media-airplay-button",
|
|
4229
|
-
["media-live-button",
|
|
4230
|
-
["media-error-display",
|
|
4231
|
-
["media-remote-playback-button",
|
|
4237
|
+
["video-player", VideoPlayerElement2],
|
|
4238
|
+
["video-skin", VideoSkin2],
|
|
4239
|
+
["media-play-button", MediaPlayButton2],
|
|
4240
|
+
["media-mute-button", MediaMuteButton2],
|
|
4241
|
+
["media-fullscreen-button", MediaFullscreenButton2],
|
|
4242
|
+
["media-pip-button", MediaPipButton2],
|
|
4243
|
+
["media-time-display", MediaTimeDisplay2],
|
|
4244
|
+
["media-time-group", MediaTimeGroup2],
|
|
4245
|
+
["media-time-separator", MediaTimeSeparator2],
|
|
4246
|
+
["media-preview-time", MediaPreviewTime2],
|
|
4247
|
+
["media-progress-bar", MediaProgressBar2],
|
|
4248
|
+
["media-volume-slider", MediaVolumeSlider2],
|
|
4249
|
+
["media-settings-menu", MediaSettingsMenu2],
|
|
4250
|
+
["media-seek-button", MediaSeekButton2],
|
|
4251
|
+
["media-playback-rate-button", MediaPlaybackRateButton2],
|
|
4252
|
+
["media-airplay-button", MediaAirplayButton2],
|
|
4253
|
+
["media-live-button", MediaLiveButton2],
|
|
4254
|
+
["media-error-display", MediaErrorDisplay2],
|
|
4255
|
+
["media-remote-playback-button", MediaRemotePlaybackButton2]
|
|
4232
4256
|
];
|
|
4233
|
-
function
|
|
4257
|
+
function registerElements2() {
|
|
4234
4258
|
for (const [name, ctor] of elements) {
|
|
4235
4259
|
if (!customElements.get(name)) {
|
|
4236
4260
|
customElements.define(name, ctor);
|
|
@@ -4238,4 +4262,4 @@ function registerElements() {
|
|
|
4238
4262
|
}
|
|
4239
4263
|
}
|
|
4240
4264
|
|
|
4241
|
-
export {
|
|
4265
|
+
export { isMediaSessionSupported2, createMediaSession2, updateMetadata2, isOrientationLockSupported2, lockOrientation2, unlockOrientation2, BaseProvider2, isHTML5Source2, HTML5Provider2, html5Loader2, extractYouTubeId2, isYouTubeSource2, YouTubeProvider2, youtubeLoader2, extractVimeoId2, extractVimeoHash2, isVimeoSource2, VimeoProvider2, vimeoLoader2, isHLSSource2, isNativeHLSSupported2, HLSProvider2, hlsLoader2, isDASHSource2, DASHProvider2, dashLoader2, defaultLoaders2, findLoader2, detectMediaType2, getPreconnectHints2, Player2, createPlayer2, getPlayer2, VideoPlayerElement2, formatTime2, formatTimePhrase2, toISODuration2, resolvePlayer2, VideoSkin2, MediaPlayButton2, MediaMuteButton2, MediaFullscreenButton2, MediaPipButton2, MediaTimeDisplay2, MediaTimeGroup2, MediaTimeSeparator2, MediaPreviewTime2, MediaProgressBar2, MediaVolumeSlider2, computePosition2, applyPosition2, MediaSettingsMenu2, MediaSeekButton2, MediaPlaybackRateButton2, MediaAirplayButton2, MediaLiveButton2, MediaErrorDisplay2, MediaRemotePlaybackButton2, registerElements2 };
|