@capgo/capacitor-video-player 8.0.19 → 8.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/README.md +32 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/capgo/videoplayer/FullscreenExoPlayerFragment.java +74 -4
- package/android/src/main/java/com/capgo/videoplayer/VideoPlayer.java +3 -1
- package/android/src/main/java/com/capgo/videoplayer/VideoPlayerPlugin.java +15 -5
- package/dist/docs.json +100 -0
- package/dist/esm/definitions.d.ts +40 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web-utils/videoplayer.js +6 -4
- package/dist/esm/web-utils/videoplayer.js.map +1 -1
- package/dist/esm/web.js +29 -12
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +35 -16
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +35 -16
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/VideoPlayerPlugin/FullscreenVideoPlayer.swift +89 -2
- package/ios/Sources/VideoPlayerPlugin/VideoPlayerPlugin.swift +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -369,6 +369,7 @@ Exit player
|
|
|
369
369
|
| **`accentColor`** | <code>string</code> | ExoPlayer Progress Bar and Spinner color (Android) by Manuel García Marín (https://github.com/PhantomPainX) Must be a valid hex color code default: #FFFFFF |
|
|
370
370
|
| **`chromecast`** | <code>boolean</code> | Chromecast enable/disable (Android) by Manuel García Marín (https://github.com/PhantomPainX) default: true |
|
|
371
371
|
| **`artwork`** | <code>string</code> | Artwork url to be shown in Chromecast player by Manuel García Marín (https://github.com/PhantomPainX) default: "" |
|
|
372
|
+
| **`drm`** | <code><a href="#drmoptions">DrmOptions</a></code> | DRM configuration for protected content (iOS: FairPlay, Android: Widevine) |
|
|
372
373
|
|
|
373
374
|
|
|
374
375
|
#### SubTitleOptions
|
|
@@ -384,6 +385,37 @@ Exit player
|
|
|
384
385
|
| **getPluginVersion** | () => Promise<{ version: string; }> | Get the native Capacitor plugin version |
|
|
385
386
|
|
|
386
387
|
|
|
388
|
+
#### DrmOptions
|
|
389
|
+
|
|
390
|
+
| Prop | Type | Description |
|
|
391
|
+
| --------------- | ------------------------------------------------------------------- | ------------------------------------ |
|
|
392
|
+
| **`fairplay`** | <code><a href="#fairplaydrmoptions">FairPlayDrmOptions</a></code> | FairPlay DRM configuration (iOS) |
|
|
393
|
+
| **`playready`** | <code><a href="#playreadydrmoptions">PlayreadyDrmOptions</a></code> | PlayReady DRM configuration |
|
|
394
|
+
| **`widevine`** | <code><a href="#widevinedrmoptions">WidevineDrmOptions</a></code> | Widevine DRM configuration (Android) |
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
#### FairPlayDrmOptions
|
|
398
|
+
|
|
399
|
+
| Prop | Type | Description |
|
|
400
|
+
| ---------------------- | ------------------- | --------------------------------------------------------------------------------- |
|
|
401
|
+
| **`certificateUrl`** | <code>string</code> | The URL to fetch the FairPlay certificate |
|
|
402
|
+
| **`contentKeySpcUrl`** | <code>string</code> | The URL to send the SPC and receive the CKC license (FairPlay license server URL) |
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
#### PlayreadyDrmOptions
|
|
406
|
+
|
|
407
|
+
| Prop | Type | Description |
|
|
408
|
+
| -------------------- | ------------------- | -------------------------------------- |
|
|
409
|
+
| **`certificateUrl`** | <code>string</code> | The URL to fetch the PlayReady license |
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
#### WidevineDrmOptions
|
|
413
|
+
|
|
414
|
+
| Prop | Type | Description |
|
|
415
|
+
| -------------------- | ------------------- | ------------------------------------- |
|
|
416
|
+
| **`certificateUrl`** | <code>string</code> | The URL to fetch the Widevine license |
|
|
417
|
+
|
|
418
|
+
|
|
387
419
|
#### capVideoPlayerIdOptions
|
|
388
420
|
|
|
389
421
|
| Prop | Type | Description |
|
package/android/build.gradle
CHANGED
|
@@ -61,10 +61,10 @@ dependencies {
|
|
|
61
61
|
implementation 'com.google.android.exoplayer:exoplayer-ui:2.19.0'
|
|
62
62
|
implementation 'com.google.android.exoplayer:exoplayer-hls:2.19.1'
|
|
63
63
|
implementation 'com.google.android.exoplayer:exoplayer-dash:2.19.1'
|
|
64
|
-
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.19.
|
|
65
|
-
implementation 'com.google.android.exoplayer:extension-mediasession:2.19.
|
|
64
|
+
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.19.1'
|
|
65
|
+
implementation 'com.google.android.exoplayer:extension-mediasession:2.19.1'
|
|
66
66
|
implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
|
|
67
|
-
implementation 'com.google.android.exoplayer:extension-cast:2.19.
|
|
67
|
+
implementation 'com.google.android.exoplayer:extension-cast:2.19.1'
|
|
68
68
|
implementation 'com.squareup.picasso:picasso:2.8'
|
|
69
69
|
testImplementation "junit:junit:$junitVersion"
|
|
70
70
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
@@ -121,6 +121,7 @@ public class FullscreenExoPlayerFragment extends Fragment {
|
|
|
121
121
|
public String accentColor;
|
|
122
122
|
public Boolean chromecast;
|
|
123
123
|
public String artwork;
|
|
124
|
+
public JSObject drmOptions;
|
|
124
125
|
|
|
125
126
|
private static final String TAG = FullscreenExoPlayerFragment.class.getName();
|
|
126
127
|
public static final long UNKNOWN_TIME = -1L;
|
|
@@ -910,23 +911,27 @@ public class FullscreenExoPlayerFragment extends Fragment {
|
|
|
910
911
|
|
|
911
912
|
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, httpDataSourceFactory);
|
|
912
913
|
|
|
914
|
+
// Build the MediaItem, applying Widevine DRM configuration if provided
|
|
915
|
+
MediaItem mediaItem = buildMediaItem(uri);
|
|
916
|
+
|
|
913
917
|
if (
|
|
914
918
|
vType.equals("mp4") ||
|
|
915
919
|
vType.equals("webm") ||
|
|
916
920
|
vType.equals("ogv") ||
|
|
917
921
|
vType.equals("3gp") ||
|
|
918
922
|
vType.equals("flv") ||
|
|
923
|
+
vType.equals("ytube") ||
|
|
919
924
|
vType.equals("")
|
|
920
925
|
) {
|
|
921
|
-
mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(
|
|
926
|
+
mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem);
|
|
922
927
|
} else if (vType.equals("dash") || vType.equals("mpd")) {
|
|
923
928
|
/* adaptive streaming Dash stream */
|
|
924
929
|
DashMediaSource.Factory mediaSourceFactory = new DashMediaSource.Factory(dataSourceFactory);
|
|
925
|
-
mediaSource = mediaSourceFactory.createMediaSource(
|
|
930
|
+
mediaSource = mediaSourceFactory.createMediaSource(mediaItem);
|
|
926
931
|
} else if (vType.equals("m3u8")) {
|
|
927
|
-
mediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(
|
|
932
|
+
mediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem);
|
|
928
933
|
} else if (vType.equals("ism")) {
|
|
929
|
-
mediaSource = new SsMediaSource.Factory(dataSourceFactory).createMediaSource(
|
|
934
|
+
mediaSource = new SsMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem);
|
|
930
935
|
}
|
|
931
936
|
// Get the subtitles if any
|
|
932
937
|
if (sturi != null) {
|
|
@@ -935,6 +940,28 @@ public class FullscreenExoPlayerFragment extends Fragment {
|
|
|
935
940
|
return mediaSource;
|
|
936
941
|
}
|
|
937
942
|
|
|
943
|
+
/**
|
|
944
|
+
* Build a MediaItem for the given URI, applying Widevine DRM configuration if provided
|
|
945
|
+
* @param uri the media URI
|
|
946
|
+
* @return MediaItem
|
|
947
|
+
*/
|
|
948
|
+
private MediaItem buildMediaItem(Uri uri) {
|
|
949
|
+
String widevineLicenseUrl = null;
|
|
950
|
+
if (drmOptions != null) {
|
|
951
|
+
JSObject widevineOptions = drmOptions.getJSObject("widevine");
|
|
952
|
+
if (widevineOptions != null && widevineOptions.has("certificateUrl")) {
|
|
953
|
+
widevineLicenseUrl = widevineOptions.getString("certificateUrl");
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (widevineLicenseUrl != null && !widevineLicenseUrl.isEmpty()) {
|
|
957
|
+
MediaItem.DrmConfiguration drmConfig = new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
|
|
958
|
+
.setLicenseUri(widevineLicenseUrl)
|
|
959
|
+
.build();
|
|
960
|
+
return new MediaItem.Builder().setUri(uri).setDrmConfiguration(drmConfig).build();
|
|
961
|
+
}
|
|
962
|
+
return MediaItem.fromUri(uri);
|
|
963
|
+
}
|
|
964
|
+
|
|
938
965
|
/**
|
|
939
966
|
* Save instance state
|
|
940
967
|
*/
|
|
@@ -1183,6 +1210,49 @@ public class FullscreenExoPlayerFragment extends Fragment {
|
|
|
1183
1210
|
* @return video type
|
|
1184
1211
|
*/
|
|
1185
1212
|
private String getVideoType(Uri uri) {
|
|
1213
|
+
// Check host for YouTube-related domains
|
|
1214
|
+
String host = uri.getHost();
|
|
1215
|
+
if (host != null) {
|
|
1216
|
+
String hostLower = host.toLowerCase(Locale.US);
|
|
1217
|
+
if (
|
|
1218
|
+
hostLower.equals("youtube.com") ||
|
|
1219
|
+
hostLower.endsWith(".youtube.com") ||
|
|
1220
|
+
hostLower.equals("youtu.be") ||
|
|
1221
|
+
hostLower.endsWith(".youtu.be")
|
|
1222
|
+
) {
|
|
1223
|
+
return "ytube";
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// Check URL path for HLS/DASH manifest patterns common in YouTube CDN URLs
|
|
1228
|
+
String path = uri.getPath();
|
|
1229
|
+
if (path != null) {
|
|
1230
|
+
String pathLower = path.toLowerCase(Locale.US);
|
|
1231
|
+
if (pathLower.contains("/hls_playlist") || pathLower.contains("/hls_manifest")) {
|
|
1232
|
+
return "m3u8";
|
|
1233
|
+
}
|
|
1234
|
+
if (pathLower.contains("/dash_playlist") || pathLower.contains("/dash_manifest")) {
|
|
1235
|
+
return "mpd";
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// Check the mime query parameter present in YouTube CDN stream URLs
|
|
1240
|
+
// e.g. mime=application%2Fx-mpegURL or mime=video%2Fmp4
|
|
1241
|
+
String mimeParam = uri.getQueryParameter("mime");
|
|
1242
|
+
if (mimeParam != null) {
|
|
1243
|
+
String mimeLower = mimeParam.toLowerCase(Locale.US);
|
|
1244
|
+
if (mimeLower.contains("mpegurl") || mimeLower.contains("m3u8")) {
|
|
1245
|
+
return "m3u8";
|
|
1246
|
+
}
|
|
1247
|
+
if (mimeLower.contains("dash+xml")) {
|
|
1248
|
+
return "mpd";
|
|
1249
|
+
}
|
|
1250
|
+
if (mimeLower.contains("mp4") || mimeLower.contains("webm") || mimeLower.contains("ogg") || mimeLower.contains("3gp")) {
|
|
1251
|
+
return ""; // empty string signals progressive format in this codebase
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
// Fall back to path-segment based detection
|
|
1186
1256
|
String ret = null;
|
|
1187
1257
|
Object obj = uri.getLastPathSegment();
|
|
1188
1258
|
String lastSegment = (obj == null) ? "" : uri.getLastPathSegment();
|
|
@@ -33,7 +33,8 @@ public class VideoPlayer {
|
|
|
33
33
|
Boolean isTV,
|
|
34
34
|
String playerId,
|
|
35
35
|
Boolean isInternal,
|
|
36
|
-
Long videoId
|
|
36
|
+
Long videoId,
|
|
37
|
+
JSObject drmOptions
|
|
37
38
|
) {
|
|
38
39
|
FullscreenExoPlayerFragment fsFragment = new FullscreenExoPlayerFragment();
|
|
39
40
|
|
|
@@ -58,6 +59,7 @@ public class VideoPlayer {
|
|
|
58
59
|
fsFragment.playerId = playerId;
|
|
59
60
|
fsFragment.isInternal = isInternal;
|
|
60
61
|
fsFragment.videoId = videoId;
|
|
62
|
+
fsFragment.drmOptions = drmOptions;
|
|
61
63
|
return fsFragment;
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -38,7 +38,7 @@ import java.util.Map;
|
|
|
38
38
|
)
|
|
39
39
|
public class VideoPlayerPlugin extends Plugin {
|
|
40
40
|
|
|
41
|
-
private final String pluginVersion = "8.
|
|
41
|
+
private final String pluginVersion = "8.1.1";
|
|
42
42
|
|
|
43
43
|
// Permission alias constants
|
|
44
44
|
private static final String PERMISSION_DENIED_ERROR = "Unable to access media videos, user denied permission request";
|
|
@@ -81,6 +81,7 @@ public class VideoPlayerPlugin extends Plugin {
|
|
|
81
81
|
private String subtitle = "";
|
|
82
82
|
private String language = "";
|
|
83
83
|
private JSObject subTitleOptions;
|
|
84
|
+
private JSObject drmOptions;
|
|
84
85
|
private final JSObject ret = new JSObject();
|
|
85
86
|
|
|
86
87
|
@Override
|
|
@@ -218,6 +219,11 @@ public class VideoPlayerPlugin extends Plugin {
|
|
|
218
219
|
_artwork = call.getString("artwork");
|
|
219
220
|
}
|
|
220
221
|
artwork = _artwork;
|
|
222
|
+
JSObject _drmOptions = null;
|
|
223
|
+
if (call.getData().has("drm")) {
|
|
224
|
+
_drmOptions = call.getObject("drm");
|
|
225
|
+
}
|
|
226
|
+
drmOptions = _drmOptions;
|
|
221
227
|
AddObserversToNotificationCenter();
|
|
222
228
|
Log.v(TAG, "display url: " + url);
|
|
223
229
|
Log.v(TAG, "display subtitle: " + subtitle);
|
|
@@ -926,7 +932,8 @@ public class VideoPlayerPlugin extends Plugin {
|
|
|
926
932
|
isTV,
|
|
927
933
|
playerId,
|
|
928
934
|
false,
|
|
929
|
-
null
|
|
935
|
+
null,
|
|
936
|
+
drmOptions
|
|
930
937
|
);
|
|
931
938
|
} else {
|
|
932
939
|
Map<String, Object> info = new HashMap<String, Object>() {
|
|
@@ -1091,7 +1098,8 @@ public class VideoPlayerPlugin extends Plugin {
|
|
|
1091
1098
|
isTV,
|
|
1092
1099
|
fsPlayerId,
|
|
1093
1100
|
true,
|
|
1094
|
-
videoId
|
|
1101
|
+
videoId,
|
|
1102
|
+
null
|
|
1095
1103
|
);
|
|
1096
1104
|
} else {
|
|
1097
1105
|
Toast.makeText(context, "No Video files found ", Toast.LENGTH_SHORT).show();
|
|
@@ -1130,7 +1138,8 @@ public class VideoPlayerPlugin extends Plugin {
|
|
|
1130
1138
|
Boolean isTV,
|
|
1131
1139
|
String playerId,
|
|
1132
1140
|
Boolean isInternal,
|
|
1133
|
-
Long videoId
|
|
1141
|
+
Long videoId,
|
|
1142
|
+
JSObject drmOptions
|
|
1134
1143
|
) {
|
|
1135
1144
|
Log.v(TAG, "§§§§ createFullScreenFragment chromecast: " + chromecast);
|
|
1136
1145
|
|
|
@@ -1155,7 +1164,8 @@ public class VideoPlayerPlugin extends Plugin {
|
|
|
1155
1164
|
isTV,
|
|
1156
1165
|
playerId,
|
|
1157
1166
|
isInternal,
|
|
1158
|
-
videoId
|
|
1167
|
+
videoId,
|
|
1168
|
+
drmOptions
|
|
1159
1169
|
);
|
|
1160
1170
|
bridge
|
|
1161
1171
|
.getActivity()
|
package/dist/docs.json
CHANGED
|
@@ -503,6 +503,15 @@
|
|
|
503
503
|
"docs": "Artwork url to be shown in Chromecast player\nby Manuel García Marín (https://github.com/PhantomPainX)\ndefault: \"\"",
|
|
504
504
|
"complexTypes": [],
|
|
505
505
|
"type": "string | undefined"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"name": "drm",
|
|
509
|
+
"tags": [],
|
|
510
|
+
"docs": "DRM configuration for protected content (iOS: FairPlay, Android: Widevine)",
|
|
511
|
+
"complexTypes": [
|
|
512
|
+
"DrmOptions"
|
|
513
|
+
],
|
|
514
|
+
"type": "DrmOptions"
|
|
506
515
|
}
|
|
507
516
|
]
|
|
508
517
|
},
|
|
@@ -556,6 +565,97 @@
|
|
|
556
565
|
}
|
|
557
566
|
]
|
|
558
567
|
},
|
|
568
|
+
{
|
|
569
|
+
"name": "DrmOptions",
|
|
570
|
+
"slug": "drmoptions",
|
|
571
|
+
"docs": "",
|
|
572
|
+
"tags": [],
|
|
573
|
+
"methods": [],
|
|
574
|
+
"properties": [
|
|
575
|
+
{
|
|
576
|
+
"name": "fairplay",
|
|
577
|
+
"tags": [],
|
|
578
|
+
"docs": "FairPlay DRM configuration (iOS)",
|
|
579
|
+
"complexTypes": [
|
|
580
|
+
"FairPlayDrmOptions"
|
|
581
|
+
],
|
|
582
|
+
"type": "FairPlayDrmOptions"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
"name": "playready",
|
|
586
|
+
"tags": [],
|
|
587
|
+
"docs": "PlayReady DRM configuration",
|
|
588
|
+
"complexTypes": [
|
|
589
|
+
"PlayreadyDrmOptions"
|
|
590
|
+
],
|
|
591
|
+
"type": "PlayreadyDrmOptions"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
"name": "widevine",
|
|
595
|
+
"tags": [],
|
|
596
|
+
"docs": "Widevine DRM configuration (Android)",
|
|
597
|
+
"complexTypes": [
|
|
598
|
+
"WidevineDrmOptions"
|
|
599
|
+
],
|
|
600
|
+
"type": "WidevineDrmOptions"
|
|
601
|
+
}
|
|
602
|
+
]
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
"name": "FairPlayDrmOptions",
|
|
606
|
+
"slug": "fairplaydrmoptions",
|
|
607
|
+
"docs": "",
|
|
608
|
+
"tags": [],
|
|
609
|
+
"methods": [],
|
|
610
|
+
"properties": [
|
|
611
|
+
{
|
|
612
|
+
"name": "certificateUrl",
|
|
613
|
+
"tags": [],
|
|
614
|
+
"docs": "The URL to fetch the FairPlay certificate",
|
|
615
|
+
"complexTypes": [],
|
|
616
|
+
"type": "string | undefined"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"name": "contentKeySpcUrl",
|
|
620
|
+
"tags": [],
|
|
621
|
+
"docs": "The URL to send the SPC and receive the CKC license (FairPlay license server URL)",
|
|
622
|
+
"complexTypes": [],
|
|
623
|
+
"type": "string | undefined"
|
|
624
|
+
}
|
|
625
|
+
]
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"name": "PlayreadyDrmOptions",
|
|
629
|
+
"slug": "playreadydrmoptions",
|
|
630
|
+
"docs": "",
|
|
631
|
+
"tags": [],
|
|
632
|
+
"methods": [],
|
|
633
|
+
"properties": [
|
|
634
|
+
{
|
|
635
|
+
"name": "certificateUrl",
|
|
636
|
+
"tags": [],
|
|
637
|
+
"docs": "The URL to fetch the PlayReady license",
|
|
638
|
+
"complexTypes": [],
|
|
639
|
+
"type": "string | undefined"
|
|
640
|
+
}
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"name": "WidevineDrmOptions",
|
|
645
|
+
"slug": "widevinedrmoptions",
|
|
646
|
+
"docs": "",
|
|
647
|
+
"tags": [],
|
|
648
|
+
"methods": [],
|
|
649
|
+
"properties": [
|
|
650
|
+
{
|
|
651
|
+
"name": "certificateUrl",
|
|
652
|
+
"tags": [],
|
|
653
|
+
"docs": "The URL to fetch the Widevine license",
|
|
654
|
+
"complexTypes": [],
|
|
655
|
+
"type": "string | undefined"
|
|
656
|
+
}
|
|
657
|
+
]
|
|
658
|
+
},
|
|
559
659
|
{
|
|
560
660
|
"name": "capVideoPlayerIdOptions",
|
|
561
661
|
"slug": "capvideoplayeridoptions",
|
|
@@ -201,6 +201,10 @@ export interface capVideoPlayerOptions {
|
|
|
201
201
|
* default: ""
|
|
202
202
|
*/
|
|
203
203
|
artwork?: string;
|
|
204
|
+
/**
|
|
205
|
+
* DRM configuration for protected content (iOS: FairPlay, Android: Widevine)
|
|
206
|
+
*/
|
|
207
|
+
drm?: DrmOptions;
|
|
204
208
|
}
|
|
205
209
|
export interface capVideoPlayerIdOptions {
|
|
206
210
|
/**
|
|
@@ -309,3 +313,39 @@ export interface SubTitleOptions {
|
|
|
309
313
|
version: string;
|
|
310
314
|
}>;
|
|
311
315
|
}
|
|
316
|
+
export interface FairPlayDrmOptions {
|
|
317
|
+
/**
|
|
318
|
+
* The URL to fetch the FairPlay certificate
|
|
319
|
+
*/
|
|
320
|
+
certificateUrl?: string;
|
|
321
|
+
/**
|
|
322
|
+
* The URL to send the SPC and receive the CKC license (FairPlay license server URL)
|
|
323
|
+
*/
|
|
324
|
+
contentKeySpcUrl?: string;
|
|
325
|
+
}
|
|
326
|
+
export interface PlayreadyDrmOptions {
|
|
327
|
+
/**
|
|
328
|
+
* The URL to fetch the PlayReady license
|
|
329
|
+
*/
|
|
330
|
+
certificateUrl?: string;
|
|
331
|
+
}
|
|
332
|
+
export interface WidevineDrmOptions {
|
|
333
|
+
/**
|
|
334
|
+
* The URL to fetch the Widevine license
|
|
335
|
+
*/
|
|
336
|
+
certificateUrl?: string;
|
|
337
|
+
}
|
|
338
|
+
export interface DrmOptions {
|
|
339
|
+
/**
|
|
340
|
+
* FairPlay DRM configuration (iOS)
|
|
341
|
+
*/
|
|
342
|
+
fairplay?: FairPlayDrmOptions;
|
|
343
|
+
/**
|
|
344
|
+
* PlayReady DRM configuration
|
|
345
|
+
*/
|
|
346
|
+
playready?: PlayreadyDrmOptions;
|
|
347
|
+
/**
|
|
348
|
+
* Widevine DRM configuration (Android)
|
|
349
|
+
*/
|
|
350
|
+
widevine?: WidevineDrmOptions;
|
|
351
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface VideoPlayerPlugin {\n /**\n * Initialize a video player\n *\n */\n initPlayer(options: capVideoPlayerOptions): Promise<capVideoPlayerResult>;\n /**\n * Return if a given playerId is playing\n *\n */\n isPlaying(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Play the current video from a given playerId\n *\n */\n play(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Pause the current video from a given playerId\n *\n */\n pause(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the duration of the current video from a given playerId\n *\n */\n getDuration(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the current time of the current video from a given playerId\n *\n */\n getCurrentTime(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the current time to seek the current video to from a given playerId\n *\n */\n setCurrentTime(options: capVideoTimeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the volume of the current video from a given playerId\n *\n */\n getVolume(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the volume of the current video to from a given playerId\n *\n */\n setVolume(options: capVideoVolumeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the muted of the current video from a given playerId\n *\n */\n getMuted(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the muted of the current video to from a given playerId\n *\n */\n setMuted(options: capVideoMutedOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the rate of the current video from a given playerId\n *\n */\n setRate(options: capVideoRateOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the rate of the current video from a given playerId\n *\n */\n getRate(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Stop all players playing\n *\n */\n stopAllPlayers(): Promise<capVideoPlayerResult>;\n /**\n * Show controller\n *\n */\n showController(): Promise<capVideoPlayerResult>;\n /**\n * isControllerIsFullyVisible\n *\n */\n isControllerIsFullyVisible(): Promise<capVideoPlayerResult>;\n /**\n * Exit player\n *\n */\n exitPlayer(): Promise<capVideoPlayerResult>;\n}\nexport interface capEchoOptions {\n /**\n * String to be echoed\n */\n\n value?: string;\n}\nexport interface capVideoPlayerOptions {\n /**\n * Player mode\n * - \"fullscreen\"\n * - \"embedded\" (Web only)\n */\n mode?: string;\n /**\n * The url of the video to play\n */\n url?: string;\n /**\n * The url of subtitle associated with the video\n */\n subtitle?: string;\n /**\n * The language of subtitle\n * see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers\n */\n language?: string;\n /**\n * SubTitle Options\n */\n subtitleOptions?: SubTitleOptions;\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Initial playing rate\n */\n rate?: number;\n /**\n * Exit on VideoEnd (iOS, Android)\n * default: true\n */\n exitOnEnd?: boolean;\n /**\n * Loop on VideoEnd when exitOnEnd false (iOS, Android)\n * default: false\n */\n loopOnEnd?: boolean;\n /**\n * Picture in Picture Enable (iOS, Android)\n * default: true\n */\n pipEnabled?: boolean;\n /**\n * Background Mode Enable (iOS, Android)\n * default: true\n */\n bkmodeEnabled?: boolean;\n /**\n * Show Controls Enable (iOS, Android)\n * default: true\n */\n showControls?: boolean;\n /**\n * Display Mode [\"all\", \"portrait\", \"landscape\"] (iOS, Android)\n * default: \"all\"\n */\n displayMode?: string;\n /**\n * Component Tag or DOM Element Tag (React app)\n */\n componentTag?: string;\n /**\n * Player Width (mode \"embedded\" only)\n */\n width?: number;\n /**\n * Player height (mode \"embedded\" only)\n */\n height?: number;\n /**\n * Headers for the request (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n headers?: {\n [key: string]: string;\n };\n /**\n * Title shown in the player (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n title?: string;\n /**\n * Subtitle shown below the title in the player (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n smallTitle?: string;\n /**\n * ExoPlayer Progress Bar and Spinner color (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * Must be a valid hex color code\n * default: #FFFFFF\n */\n accentColor?: string;\n /**\n * Chromecast enable/disable (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: true\n */\n chromecast?: boolean;\n /**\n * Artwork url to be shown in Chromecast player\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: \"\"\n */\n artwork?: string;\n}\nexport interface capVideoPlayerIdOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n}\nexport interface capVideoRateOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Rate value\n */\n rate?: number;\n}\nexport interface capVideoVolumeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Volume value between [0 - 1]\n */\n volume?: number;\n}\nexport interface capVideoTimeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video time value you want to seek to\n */\n seektime?: number;\n}\nexport interface capVideoMutedOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Muted value true or false\n */\n muted?: boolean;\n}\nexport interface capVideoListener {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capExitListener {\n /**\n * Dismiss value true or false\n */\n dismiss?: boolean;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capVideoPlayerResult {\n /**\n * result set to true when successful else false\n */\n result?: boolean;\n /**\n * method name\n */\n method?: string;\n /**\n * value returned\n */\n value?: any;\n /**\n * message string\n */\n message?: string;\n}\nexport interface SubTitleOptions {\n /**\n * Foreground Color in RGBA (default rgba(255,255,255,1)\n */\n foregroundColor?: string;\n /**\n * Background Color in RGBA (default rgba(0,0,0,1)\n */\n backgroundColor?: string;\n /**\n * Font Size in pixels (default 16)\n */\n fontSize?: number;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface VideoPlayerPlugin {\n /**\n * Initialize a video player\n *\n */\n initPlayer(options: capVideoPlayerOptions): Promise<capVideoPlayerResult>;\n /**\n * Return if a given playerId is playing\n *\n */\n isPlaying(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Play the current video from a given playerId\n *\n */\n play(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Pause the current video from a given playerId\n *\n */\n pause(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the duration of the current video from a given playerId\n *\n */\n getDuration(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the current time of the current video from a given playerId\n *\n */\n getCurrentTime(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the current time to seek the current video to from a given playerId\n *\n */\n setCurrentTime(options: capVideoTimeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the volume of the current video from a given playerId\n *\n */\n getVolume(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the volume of the current video to from a given playerId\n *\n */\n setVolume(options: capVideoVolumeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the muted of the current video from a given playerId\n *\n */\n getMuted(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the muted of the current video to from a given playerId\n *\n */\n setMuted(options: capVideoMutedOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the rate of the current video from a given playerId\n *\n */\n setRate(options: capVideoRateOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the rate of the current video from a given playerId\n *\n */\n getRate(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Stop all players playing\n *\n */\n stopAllPlayers(): Promise<capVideoPlayerResult>;\n /**\n * Show controller\n *\n */\n showController(): Promise<capVideoPlayerResult>;\n /**\n * isControllerIsFullyVisible\n *\n */\n isControllerIsFullyVisible(): Promise<capVideoPlayerResult>;\n /**\n * Exit player\n *\n */\n exitPlayer(): Promise<capVideoPlayerResult>;\n}\nexport interface capEchoOptions {\n /**\n * String to be echoed\n */\n\n value?: string;\n}\nexport interface capVideoPlayerOptions {\n /**\n * Player mode\n * - \"fullscreen\"\n * - \"embedded\" (Web only)\n */\n mode?: string;\n /**\n * The url of the video to play\n */\n url?: string;\n /**\n * The url of subtitle associated with the video\n */\n subtitle?: string;\n /**\n * The language of subtitle\n * see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers\n */\n language?: string;\n /**\n * SubTitle Options\n */\n subtitleOptions?: SubTitleOptions;\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Initial playing rate\n */\n rate?: number;\n /**\n * Exit on VideoEnd (iOS, Android)\n * default: true\n */\n exitOnEnd?: boolean;\n /**\n * Loop on VideoEnd when exitOnEnd false (iOS, Android)\n * default: false\n */\n loopOnEnd?: boolean;\n /**\n * Picture in Picture Enable (iOS, Android)\n * default: true\n */\n pipEnabled?: boolean;\n /**\n * Background Mode Enable (iOS, Android)\n * default: true\n */\n bkmodeEnabled?: boolean;\n /**\n * Show Controls Enable (iOS, Android)\n * default: true\n */\n showControls?: boolean;\n /**\n * Display Mode [\"all\", \"portrait\", \"landscape\"] (iOS, Android)\n * default: \"all\"\n */\n displayMode?: string;\n /**\n * Component Tag or DOM Element Tag (React app)\n */\n componentTag?: string;\n /**\n * Player Width (mode \"embedded\" only)\n */\n width?: number;\n /**\n * Player height (mode \"embedded\" only)\n */\n height?: number;\n /**\n * Headers for the request (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n headers?: {\n [key: string]: string;\n };\n /**\n * Title shown in the player (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n title?: string;\n /**\n * Subtitle shown below the title in the player (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n smallTitle?: string;\n /**\n * ExoPlayer Progress Bar and Spinner color (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * Must be a valid hex color code\n * default: #FFFFFF\n */\n accentColor?: string;\n /**\n * Chromecast enable/disable (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: true\n */\n chromecast?: boolean;\n /**\n * Artwork url to be shown in Chromecast player\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: \"\"\n */\n artwork?: string;\n /**\n * DRM configuration for protected content (iOS: FairPlay, Android: Widevine)\n */\n drm?: DrmOptions;\n}\nexport interface capVideoPlayerIdOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n}\nexport interface capVideoRateOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Rate value\n */\n rate?: number;\n}\nexport interface capVideoVolumeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Volume value between [0 - 1]\n */\n volume?: number;\n}\nexport interface capVideoTimeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video time value you want to seek to\n */\n seektime?: number;\n}\nexport interface capVideoMutedOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Muted value true or false\n */\n muted?: boolean;\n}\nexport interface capVideoListener {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capExitListener {\n /**\n * Dismiss value true or false\n */\n dismiss?: boolean;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capVideoPlayerResult {\n /**\n * result set to true when successful else false\n */\n result?: boolean;\n /**\n * method name\n */\n method?: string;\n /**\n * value returned\n */\n value?: any;\n /**\n * message string\n */\n message?: string;\n}\nexport interface SubTitleOptions {\n /**\n * Foreground Color in RGBA (default rgba(255,255,255,1)\n */\n foregroundColor?: string;\n /**\n * Background Color in RGBA (default rgba(0,0,0,1)\n */\n backgroundColor?: string;\n /**\n * Font Size in pixels (default 16)\n */\n fontSize?: number;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\nexport interface FairPlayDrmOptions {\n /**\n * The URL to fetch the FairPlay certificate\n */\n certificateUrl?: string;\n /**\n * The URL to send the SPC and receive the CKC license (FairPlay license server URL)\n */\n contentKeySpcUrl?: string;\n}\nexport interface PlayreadyDrmOptions {\n /**\n * The URL to fetch the PlayReady license\n */\n certificateUrl?: string;\n}\nexport interface WidevineDrmOptions {\n /**\n * The URL to fetch the Widevine license\n */\n certificateUrl?: string;\n}\nexport interface DrmOptions {\n /**\n * FairPlay DRM configuration (iOS)\n */\n fairplay?: FairPlayDrmOptions;\n /**\n * PlayReady DRM configuration\n */\n playready?: PlayreadyDrmOptions;\n /**\n * Widevine DRM configuration (Android)\n */\n widevine?: WidevineDrmOptions;\n}\n"]}
|
|
@@ -242,20 +242,22 @@ export class VideoPlayer {
|
|
|
242
242
|
_getVideoType() {
|
|
243
243
|
const sUrl = this._url ? this._url : '';
|
|
244
244
|
if (sUrl != null && sUrl.length > 0) {
|
|
245
|
-
|
|
245
|
+
for (const [extension, mimeType] of Object.entries(videoTypes)) {
|
|
246
246
|
// we search for dot + extension (e.g. `.mp4`) for URLs that have the extension in the filename
|
|
247
247
|
// e.g. https://vimeo.com/?file=my-video.mp4
|
|
248
|
-
const hasDotExtension = sUrl.match(new RegExp(
|
|
248
|
+
const hasDotExtension = sUrl.match(new RegExp(`\\.(${extension})(?=[?&#]|$)`, 'i'));
|
|
249
249
|
if (hasDotExtension) {
|
|
250
250
|
return (this._videoType = mimeType);
|
|
251
251
|
}
|
|
252
|
+
}
|
|
253
|
+
for (const [extension, mimeType] of Object.entries(videoTypes)) {
|
|
252
254
|
// we search for the extension (e.g. `m3u8`) for URLs that might have the extension as a query parameter
|
|
253
255
|
// e.g. https://youtube.com/?v=7894289374&type=m3u8
|
|
254
256
|
const hasExtensionInUrl = sUrl.match(new RegExp(`(${extension})`, 'i'));
|
|
255
257
|
if (hasExtensionInUrl) {
|
|
256
258
|
return (this._videoType = mimeType);
|
|
257
259
|
}
|
|
258
|
-
}
|
|
260
|
+
}
|
|
259
261
|
// we check for not supported extensions for URLs that have the extension in the filename
|
|
260
262
|
// e.g. https://vimeo.com/?file=not-supported-extension-video.mkv
|
|
261
263
|
const hasNotSupportedDotExtension = sUrl.match(/\.(.*)/i);
|
|
@@ -264,7 +266,7 @@ export class VideoPlayer {
|
|
|
264
266
|
}
|
|
265
267
|
// we check for not supported extensions for URLs that might have the extension as a query parameter
|
|
266
268
|
// e.g. https://youtube.com/?v=3982748927&filetype=mkv
|
|
267
|
-
const hasNotSupportedExtensionInUrl = sUrl.match(new RegExp(`(${possibleQueryParameterExtensions.join('|')})=+(.*)&?(?=&|$)
|
|
269
|
+
const hasNotSupportedExtensionInUrl = sUrl.match(new RegExp(`(${possibleQueryParameterExtensions.join('|')})=+(.*)&?(?=&|$)`, 'i'));
|
|
268
270
|
if (hasNotSupportedExtensionInUrl) {
|
|
269
271
|
return (this._videoType = null);
|
|
270
272
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoplayer.js","sourceRoot":"","sources":["../../../src/web-utils/videoplayer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAE7E,MAAM,OAAO,WAAW;IAsBtB,YACE,IAAY,EACZ,GAAW,EACX,QAAgB,EAChB,IAAY,EACZ,SAAkB,EAClB,SAAkB,EAClB,SAAc,EACd,MAAc,EACd,KAAc,EACd,MAAe;QA9BV,YAAO,GAAG,KAAK,CAAC;QAYf,eAAU,GAAyB,IAAI,CAAC;QACxC,oBAAe,GAAQ,IAAI,CAAC;QAC5B,sBAAiB,GAAG,IAAI,CAAC;QACzB,aAAQ,GAAG,KAAK,CAAC;QACjB,eAAU,GAAG,GAAG,CAAC;QACjB,oBAAe,GAAG,IAAI,CAAC;QACvB,oBAAe,GAAG,KAAK,CAAC;QAc9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,C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port { videoTypes, possibleQueryParameterExtensions } from './video-types';\n\nexport class VideoPlayer {\n public videoEl: HTMLVideoElement | undefined;\n public pipMode = false;\n public pipWindow: Window | undefined;\n public isPlaying: boolean | undefined;\n\n private _url: string;\n private _playerId: string;\n private _container: any;\n private _mode: string;\n private _width: number;\n private _height: number;\n private _zIndex: number;\n private _initial: any;\n private _videoType: videoMimeType | null = null;\n private _videoContainer: any = null;\n private _firstReadyToPlay = true;\n private _isEnded = false;\n private _videoRate = 1.0;\n private _videoExitOnEnd = true;\n private _videoLoopOnEnd = false;\n\n constructor(\n mode: string,\n url: string,\n playerId: string,\n rate: number,\n exitOnEnd: boolean,\n loopOnEnd: boolean,\n container: any,\n zIndex: number,\n width?: number,\n height?: number,\n ) {\n this._url = url;\n this._container = container;\n this._mode = mode;\n this._width = width ? width : 320;\n this._height = height ? height : 180;\n this._mode = mode;\n this._videoRate = rate;\n this._zIndex = zIndex ? zIndex : 1;\n this._playerId = playerId;\n this._videoExitOnEnd = exitOnEnd;\n this._videoLoopOnEnd = loopOnEnd;\n }\n\n public async initialize(): Promise<void> {\n // get the video type\n const urlVideoType: videoMimeType | null = this._getVideoType();\n if (urlVideoType) {\n // style the container\n if (this._mode === 'fullscreen') {\n this._container.style.position = 'absolute';\n this._container.style.width = '100vw';\n this._container.style.height = '100vh';\n }\n if (this._mode === 'embedded') {\n this._container.style.position = 'relative';\n this._container.style.width = this._width.toString() + 'px';\n this._container.style.height = this._height.toString() + 'px';\n }\n this._container.style.left = '0';\n this._container.style.top = '0';\n this._container.style.display = 'flex';\n this._container.style.alignItems = 'center';\n this._container.style.justifyContent = 'center';\n this._container.style.backgroundColor = '#000000';\n this._container.style.zIndex = this._zIndex.toString();\n const width: number =\n this._mode === 'fullscreen' ? window.innerWidth /*this._container.offsetWidth*/ : this._width;\n const height: number =\n this._mode === 'fullscreen' ? window.innerHeight /*this._container.offsetHeight*/ : this._height;\n const xmlns = 'http://www.w3.org/2000/svg';\n\n const svg = document.createElementNS(xmlns, 'svg');\n svg.setAttributeNS(null, 'width', width.toString());\n svg.setAttributeNS(null, 'height', height.toString());\n const viewbox = '0 0 ' + width.toString() + ' ' + height.toString();\n svg.setAttributeNS(null, 'viewBox', viewbox);\n svg.style.zIndex = (this._zIndex + 1).toString();\n const rect = document.createElementNS(xmlns, 'rect');\n rect.setAttributeNS(null, 'x', '0');\n rect.setAttributeNS(null, 'y', '0');\n rect.setAttributeNS(null, 'width', width.toString());\n rect.setAttributeNS(null, 'height', height.toString());\n rect.setAttributeNS(null, 'fill', '#000000');\n svg.appendChild(rect);\n this._container.appendChild(svg);\n\n const heightVideo: number = (width * this._height) / this._width;\n this._videoContainer = document.createElement('div');\n this._videoContainer.style.position = 'absolute';\n this._videoContainer.style.left = '0';\n this._videoContainer.style.width = width.toString() + 'px';\n this._videoContainer.style.height = heightVideo.toString() + 'px';\n this._videoContainer.style.zIndex = (this._zIndex + 2).toString();\n this._container.appendChild(this._videoContainer);\n /* Create Video Element */\n const isCreated = await this.createVideoElement(width, heightVideo);\n if (!isCreated) {\n this._createEvent('Exit', this._playerId, 'Video Error: failed to create the Video Element');\n }\n } else {\n this._createEvent('Exit', this._playerId, 'Url Error: type not supported');\n }\n return;\n }\n\n private async createVideoElement(width: number, height: number): Promise<boolean> {\n this.videoEl = document.createElement('video');\n this.videoEl.controls = true;\n this.videoEl.style.zIndex = (this._zIndex + 3).toString();\n this.videoEl.style.width = `${width.toString()}px`;\n this.videoEl.style.height = `${height.toString()}px`;\n this.videoEl.playbackRate = this._videoRate;\n this._videoContainer.appendChild(this.videoEl);\n // set the player\n const isSet: boolean = await this._setPlayer();\n if (isSet) {\n this.videoEl.onended = async () => {\n this._isEnded = true;\n this.isPlaying = false;\n if (this.videoEl) {\n this.videoEl.currentTime = 0;\n }\n if (this._videoExitOnEnd) {\n if (this._mode === 'fullscreen') {\n this._closeFullscreen();\n }\n this._createEvent('Ended', this._playerId);\n } else {\n if (this._videoLoopOnEnd && this.videoEl != null) {\n await this.videoEl.play();\n }\n }\n };\n this.videoEl.oncanplay = async () => {\n if (this._firstReadyToPlay) {\n this._createEvent('Ready', this._playerId);\n if (this.videoEl != null) {\n this.videoEl.muted = false;\n if (this._mode === 'fullscreen') await this.videoEl.play();\n this._firstReadyToPlay = false;\n }\n }\n };\n this.videoEl.onplay = () => {\n this.isPlaying = true;\n if (this._firstReadyToPlay) this._firstReadyToPlay = false;\n this._createEvent('Play', this._playerId);\n };\n this.videoEl.onplaying = () => {\n this._createEvent('Playing', this._playerId);\n };\n this.videoEl.onpause = () => {\n this.isPlaying = false;\n this._createEvent('Pause', this._playerId);\n };\n if (this._mode === 'fullscreen') {\n // create the video player exit button\n const exitEl: HTMLButtonElement = document.createElement('button');\n exitEl.textContent = 'X';\n exitEl.style.position = 'absolute';\n exitEl.style.left = '1%';\n exitEl.style.top = '5%';\n exitEl.style.width = '5vmin';\n exitEl.style.padding = '0.5%';\n exitEl.style.fontSize = '1.2rem';\n exitEl.style.background = 'rgba(51,51,51,.4)';\n exitEl.style.color = '#fff';\n exitEl.style.visibility = 'hidden';\n exitEl.style.zIndex = (this._zIndex + 4).toString();\n exitEl.style.border = '1px solid rgba(51,51,51,.4)';\n exitEl.style.borderRadius = '20px';\n this._videoContainer.onclick = async () => {\n this._initial = await this._doHide(exitEl, 3000);\n };\n this._videoContainer.ontouchstart = async () => {\n this._initial = await this._doHide(exitEl, 3000);\n };\n\n this._videoContainer.onmousemove = async () => {\n this._initial = await this._doHide(exitEl, 3000);\n };\n\n exitEl.onclick = () => {\n this._createEvent('Exit', this._playerId);\n };\n exitEl.ontouchstart = () => {\n this._createEvent('Exit', this._playerId);\n };\n\n this._videoContainer.appendChild(exitEl);\n this._initial = await this._doHide(exitEl, 3000);\n\n this._goFullscreen();\n }\n }\n return isSet;\n }\n\n private async _goFullscreen(): Promise<void> {\n if (this._container.mozRequestFullScreen) {\n /* Firefox */\n this._container.mozRequestFullScreen();\n } else if (this._container.webkitRequestFullscreen) {\n /* Chrome, Safari & Opera */\n this._container.webkitRequestFullscreen();\n } else if (this._container.msRequestFullscreen) {\n /* IE/Edge */\n this._container.msRequestFullscreen();\n } else if (this._container.requestFullscreen) {\n this._container.requestFullscreen();\n }\n return;\n }\n\n private async _setPlayer(): Promise<boolean> {\n return new Promise((resolve) => {\n if (this.videoEl != null) {\n if (Hls.isSupported() && this._videoType === 'application/x-mpegURL') {\n const hls = new Hls();\n hls.loadSource(this._url);\n hls.attachMedia(this.videoEl);\n hls.once(Hls.Events.FRAG_PARSED, () => {\n if (this.videoEl != null) {\n this.videoEl.muted = true;\n this.videoEl.crossOrigin = 'anonymous';\n resolve(true);\n } else {\n resolve(false);\n }\n });\n } else if (this._videoType === 'video/mp4') {\n // CMAF (fMP4) && MP4\n this.videoEl.src = this._url;\n if (this._url.substring(0, 5) != 'https' && this._url.substring(0, 4) === 'http')\n this.videoEl.crossOrigin = 'anonymous';\n if (this._url.substring(0, 5) === 'https' || this._url.substring(0, 4) === 'http') this.videoEl.muted = true;\n resolve(true);\n } else {\n // Not Supported\n resolve(false);\n }\n this.videoEl.addEventListener('enterpictureinpicture', (event: any) => {\n this.pipWindow = event.pictureInPictureWindow;\n this.pipMode = true;\n this._closeFullscreen();\n });\n\n this.videoEl.addEventListener('leavepictureinpicture', () => {\n this.pipMode = false;\n if (!this._isEnded) {\n this._goFullscreen();\n if (this.videoEl != null) this.videoEl.play();\n }\n });\n } else {\n resolve(false);\n }\n });\n }\n\n private _getVideoType(): videoMimeType | null {\n const sUrl: string = this._url ? this._url : '';\n if (sUrl != null && sUrl.length > 0) {\n Object.entries(videoTypes).forEach(([extension, mimeType]) => {\n // we search for dot + extension (e.g. `.mp4`) for URLs that have the extension in the filename\n // e.g. https://vimeo.com/?file=my-video.mp4\n const hasDotExtension = sUrl.match(new RegExp(`.(${extension})`, 'i'));\n if (hasDotExtension) {\n return (this._videoType = mimeType);\n }\n // we search for the extension (e.g. `m3u8`) for URLs that might have the extension as a query parameter\n // e.g. https://youtube.com/?v=7894289374&type=m3u8\n const hasExtensionInUrl = sUrl.match(new RegExp(`(${extension})`, 'i'));\n if (hasExtensionInUrl) {\n return (this._videoType = mimeType);\n }\n });\n // we check for not supported extensions for URLs that have the extension in the filename\n // e.g. https://vimeo.com/?file=not-supported-extension-video.mkv\n const hasNotSupportedDotExtension = sUrl.match(/\\.(.*)/i);\n if (hasNotSupportedDotExtension) {\n return (this._videoType = null);\n }\n // we check for not supported extensions for URLs that might have the extension as a query parameter\n // e.g. https://youtube.com/?v=3982748927&filetype=mkv\n const hasNotSupportedExtensionInUrl = sUrl.match(\n new RegExp(`(${possibleQueryParameterExtensions.join('|')})=+(.*)&?(?=&|$))`, 'i'),\n );\n if (hasNotSupportedExtensionInUrl) {\n return (this._videoType = null);\n }\n // No extension found, then we assume it's 'mp4' (Match case for '')\n return 'video/mp4';\n }\n // URL was not defined, we return null\n return null;\n }\n\n private async _doHide(exitEl: HTMLButtonElement, duration: number) {\n clearTimeout(this._initial);\n exitEl.style.visibility = 'visible';\n const initial = setTimeout(() => {\n exitEl.style.visibility = 'hidden';\n }, duration);\n return initial;\n }\n private _createEvent(ev: string, playerId: string, msg?: string) {\n const message = msg ? msg : null;\n let event: CustomEvent;\n if (message != null) {\n event = new CustomEvent(`videoPlayer${ev}`, {\n detail: { fromPlayerId: playerId, message: message },\n });\n } else {\n const currentTime: number = this.videoEl ? this.videoEl.currentTime : 0;\n event = new CustomEvent(`videoPlayer${ev}`, {\n detail: { fromPlayerId: playerId, currentTime: currentTime },\n });\n }\n document.dispatchEvent(event);\n }\n private _closeFullscreen() {\n const mydoc: any = document;\n const isInFullScreen: boolean =\n (mydoc.fullscreenElement && mydoc.fullscreenElement !== null) ||\n (mydoc.webkitFullscreenElement && mydoc.webkitFullscreenElement !== null) ||\n (mydoc.mozFullScreenElement && mydoc.mozFullScreenElement !== null) ||\n (mydoc.msFullscreenElement && mydoc.msFullscreenElement !== null);\n if (isInFullScreen) {\n if (mydoc.mozCancelFullScreen) {\n mydoc.mozCancelFullScreen();\n } else if (mydoc.webkitExitFullscreen) {\n mydoc.webkitExitFullscreen();\n } else if (mydoc.msExitFullscreen) {\n mydoc.msExitFullscreen();\n } else if (mydoc.exitFullscreen) {\n mydoc.exitFullscreen();\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"videoplayer.js","sourceRoot":"","sources":["../../../src/web-utils/videoplayer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAE7E,MAAM,OAAO,WAAW;IAsBtB,YACE,IAAY,EACZ,GAAW,EACX,QAAgB,EAChB,IAAY,EACZ,SAAkB,EAClB,SAAkB,EAClB,SAAc,EACd,MAAc,EACd,KAAc,EACd,MAAe;QA9BV,YAAO,GAAG,KAAK,CAAC;QAYf,eAAU,GAAyB,IAAI,CAAC;QACxC,oBAAe,GAAQ,IAAI,CAAC;QAC5B,sBAAiB,GAAG,IAAI,CAAC;QACzB,aAAQ,GAAG,KAAK,CAAC;QACjB,eAAU,GAAG,GAAG,CAAC;QACjB,oBAAe,GAAG,IAAI,CAAC;QACvB,oBAAe,GAAG,KAAK,CAAC;QAc9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC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AAC;YACxE,KAAK,GAAG,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE,EAAE;gBAC1C,MAAM,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE;aAC7D,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACO,gBAAgB;QACtB,MAAM,KAAK,GAAQ,QAAQ,CAAC;QAC5B,MAAM,cAAc,GAClB,CAAC,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,iBAAiB,KAAK,IAAI,CAAC;YAC7D,CAAC,KAAK,CAAC,uBAAuB,IAAI,KAAK,CAAC,uBAAuB,KAAK,IAAI,CAAC;YACzE,CAAC,KAAK,CAAC,oBAAoB,IAAI,KAAK,CAAC,oBAAoB,KAAK,IAAI,CAAC;YACnE,CAAC,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,mBAAmB,KAAK,IAAI,CAAC,CAAC;QACpE,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,KAAK,CAAC,mBAAmB,EAAE,CAAC;gBAC9B,KAAK,CAAC,mBAAmB,EAAE,CAAC;YAC9B,CAAC;iBAAM,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;gBACtC,KAAK,CAAC,oBAAoB,EAAE,CAAC;YAC/B,CAAC;iBAAM,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;gBAClC,KAAK,CAAC,gBAAgB,EAAE,CAAC;YAC3B,CAAC;iBAAM,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;gBAChC,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import Hls from 'hls.js';\n\nimport type { videoMimeType } from './video-types';\nimport { videoTypes, possibleQueryParameterExtensions } from './video-types';\n\nexport class VideoPlayer {\n public videoEl: HTMLVideoElement | undefined;\n public pipMode = false;\n public pipWindow: Window | undefined;\n public isPlaying: boolean | undefined;\n\n private _url: string;\n private _playerId: string;\n private _container: any;\n private _mode: string;\n private _width: number;\n private _height: number;\n private _zIndex: number;\n private _initial: any;\n private _videoType: videoMimeType | null = null;\n private _videoContainer: any = null;\n private _firstReadyToPlay = true;\n private _isEnded = false;\n private _videoRate = 1.0;\n private _videoExitOnEnd = true;\n private _videoLoopOnEnd = false;\n\n constructor(\n mode: string,\n url: string,\n playerId: string,\n rate: number,\n exitOnEnd: boolean,\n loopOnEnd: boolean,\n container: any,\n zIndex: number,\n width?: number,\n height?: number,\n ) {\n this._url = url;\n this._container = container;\n this._mode = mode;\n this._width = width ? width : 320;\n this._height = height ? height : 180;\n this._mode = mode;\n this._videoRate = rate;\n this._zIndex = zIndex ? zIndex : 1;\n this._playerId = playerId;\n this._videoExitOnEnd = exitOnEnd;\n this._videoLoopOnEnd = loopOnEnd;\n }\n\n public async initialize(): Promise<void> {\n // get the video type\n const urlVideoType: videoMimeType | null = this._getVideoType();\n if (urlVideoType) {\n // style the container\n if (this._mode === 'fullscreen') {\n this._container.style.position = 'absolute';\n this._container.style.width = '100vw';\n this._container.style.height = '100vh';\n }\n if (this._mode === 'embedded') {\n this._container.style.position = 'relative';\n this._container.style.width = this._width.toString() + 'px';\n this._container.style.height = this._height.toString() + 'px';\n }\n this._container.style.left = '0';\n this._container.style.top = '0';\n this._container.style.display = 'flex';\n this._container.style.alignItems = 'center';\n this._container.style.justifyContent = 'center';\n this._container.style.backgroundColor = '#000000';\n this._container.style.zIndex = this._zIndex.toString();\n const width: number =\n this._mode === 'fullscreen' ? window.innerWidth /*this._container.offsetWidth*/ : this._width;\n const height: number =\n this._mode === 'fullscreen' ? window.innerHeight /*this._container.offsetHeight*/ : this._height;\n const xmlns = 'http://www.w3.org/2000/svg';\n\n const svg = document.createElementNS(xmlns, 'svg');\n svg.setAttributeNS(null, 'width', width.toString());\n svg.setAttributeNS(null, 'height', height.toString());\n const viewbox = '0 0 ' + width.toString() + ' ' + height.toString();\n svg.setAttributeNS(null, 'viewBox', viewbox);\n svg.style.zIndex = (this._zIndex + 1).toString();\n const rect = document.createElementNS(xmlns, 'rect');\n rect.setAttributeNS(null, 'x', '0');\n rect.setAttributeNS(null, 'y', '0');\n rect.setAttributeNS(null, 'width', width.toString());\n rect.setAttributeNS(null, 'height', height.toString());\n rect.setAttributeNS(null, 'fill', '#000000');\n svg.appendChild(rect);\n this._container.appendChild(svg);\n\n const heightVideo: number = (width * this._height) / this._width;\n this._videoContainer = document.createElement('div');\n this._videoContainer.style.position = 'absolute';\n this._videoContainer.style.left = '0';\n this._videoContainer.style.width = width.toString() + 'px';\n this._videoContainer.style.height = heightVideo.toString() + 'px';\n this._videoContainer.style.zIndex = (this._zIndex + 2).toString();\n this._container.appendChild(this._videoContainer);\n /* Create Video Element */\n const isCreated = await this.createVideoElement(width, heightVideo);\n if (!isCreated) {\n this._createEvent('Exit', this._playerId, 'Video Error: failed to create the Video Element');\n }\n } else {\n this._createEvent('Exit', this._playerId, 'Url Error: type not supported');\n }\n return;\n }\n\n private async createVideoElement(width: number, height: number): Promise<boolean> {\n this.videoEl = document.createElement('video');\n this.videoEl.controls = true;\n this.videoEl.style.zIndex = (this._zIndex + 3).toString();\n this.videoEl.style.width = `${width.toString()}px`;\n this.videoEl.style.height = `${height.toString()}px`;\n this.videoEl.playbackRate = this._videoRate;\n this._videoContainer.appendChild(this.videoEl);\n // set the player\n const isSet: boolean = await this._setPlayer();\n if (isSet) {\n this.videoEl.onended = async () => {\n this._isEnded = true;\n this.isPlaying = false;\n if (this.videoEl) {\n this.videoEl.currentTime = 0;\n }\n if (this._videoExitOnEnd) {\n if (this._mode === 'fullscreen') {\n this._closeFullscreen();\n }\n this._createEvent('Ended', this._playerId);\n } else {\n if (this._videoLoopOnEnd && this.videoEl != null) {\n await this.videoEl.play();\n }\n }\n };\n this.videoEl.oncanplay = async () => {\n if (this._firstReadyToPlay) {\n this._createEvent('Ready', this._playerId);\n if (this.videoEl != null) {\n this.videoEl.muted = false;\n if (this._mode === 'fullscreen') await this.videoEl.play();\n this._firstReadyToPlay = false;\n }\n }\n };\n this.videoEl.onplay = () => {\n this.isPlaying = true;\n if (this._firstReadyToPlay) this._firstReadyToPlay = false;\n this._createEvent('Play', this._playerId);\n };\n this.videoEl.onplaying = () => {\n this._createEvent('Playing', this._playerId);\n };\n this.videoEl.onpause = () => {\n this.isPlaying = false;\n this._createEvent('Pause', this._playerId);\n };\n if (this._mode === 'fullscreen') {\n // create the video player exit button\n const exitEl: HTMLButtonElement = document.createElement('button');\n exitEl.textContent = 'X';\n exitEl.style.position = 'absolute';\n exitEl.style.left = '1%';\n exitEl.style.top = '5%';\n exitEl.style.width = '5vmin';\n exitEl.style.padding = '0.5%';\n exitEl.style.fontSize = '1.2rem';\n exitEl.style.background = 'rgba(51,51,51,.4)';\n exitEl.style.color = '#fff';\n exitEl.style.visibility = 'hidden';\n exitEl.style.zIndex = (this._zIndex + 4).toString();\n exitEl.style.border = '1px solid rgba(51,51,51,.4)';\n exitEl.style.borderRadius = '20px';\n this._videoContainer.onclick = async () => {\n this._initial = await this._doHide(exitEl, 3000);\n };\n this._videoContainer.ontouchstart = async () => {\n this._initial = await this._doHide(exitEl, 3000);\n };\n\n this._videoContainer.onmousemove = async () => {\n this._initial = await this._doHide(exitEl, 3000);\n };\n\n exitEl.onclick = () => {\n this._createEvent('Exit', this._playerId);\n };\n exitEl.ontouchstart = () => {\n this._createEvent('Exit', this._playerId);\n };\n\n this._videoContainer.appendChild(exitEl);\n this._initial = await this._doHide(exitEl, 3000);\n\n this._goFullscreen();\n }\n }\n return isSet;\n }\n\n private async _goFullscreen(): Promise<void> {\n if (this._container.mozRequestFullScreen) {\n /* Firefox */\n this._container.mozRequestFullScreen();\n } else if (this._container.webkitRequestFullscreen) {\n /* Chrome, Safari & Opera */\n this._container.webkitRequestFullscreen();\n } else if (this._container.msRequestFullscreen) {\n /* IE/Edge */\n this._container.msRequestFullscreen();\n } else if (this._container.requestFullscreen) {\n this._container.requestFullscreen();\n }\n return;\n }\n\n private async _setPlayer(): Promise<boolean> {\n return new Promise((resolve) => {\n if (this.videoEl != null) {\n if (Hls.isSupported() && this._videoType === 'application/x-mpegURL') {\n const hls = new Hls();\n hls.loadSource(this._url);\n hls.attachMedia(this.videoEl);\n hls.once(Hls.Events.FRAG_PARSED, () => {\n if (this.videoEl != null) {\n this.videoEl.muted = true;\n this.videoEl.crossOrigin = 'anonymous';\n resolve(true);\n } else {\n resolve(false);\n }\n });\n } else if (this._videoType === 'video/mp4') {\n // CMAF (fMP4) && MP4\n this.videoEl.src = this._url;\n if (this._url.substring(0, 5) != 'https' && this._url.substring(0, 4) === 'http')\n this.videoEl.crossOrigin = 'anonymous';\n if (this._url.substring(0, 5) === 'https' || this._url.substring(0, 4) === 'http') this.videoEl.muted = true;\n resolve(true);\n } else {\n // Not Supported\n resolve(false);\n }\n this.videoEl.addEventListener('enterpictureinpicture', (event: any) => {\n this.pipWindow = event.pictureInPictureWindow;\n this.pipMode = true;\n this._closeFullscreen();\n });\n\n this.videoEl.addEventListener('leavepictureinpicture', () => {\n this.pipMode = false;\n if (!this._isEnded) {\n this._goFullscreen();\n if (this.videoEl != null) this.videoEl.play();\n }\n });\n } else {\n resolve(false);\n }\n });\n }\n\n private _getVideoType(): videoMimeType | null {\n const sUrl: string = this._url ? this._url : '';\n if (sUrl != null && sUrl.length > 0) {\n for (const [extension, mimeType] of Object.entries(videoTypes)) {\n // we search for dot + extension (e.g. `.mp4`) for URLs that have the extension in the filename\n // e.g. https://vimeo.com/?file=my-video.mp4\n const hasDotExtension = sUrl.match(new RegExp(`\\\\.(${extension})(?=[?&#]|$)`, 'i'));\n if (hasDotExtension) {\n return (this._videoType = mimeType);\n }\n }\n for (const [extension, mimeType] of Object.entries(videoTypes)) {\n // we search for the extension (e.g. `m3u8`) for URLs that might have the extension as a query parameter\n // e.g. https://youtube.com/?v=7894289374&type=m3u8\n const hasExtensionInUrl = sUrl.match(new RegExp(`(${extension})`, 'i'));\n if (hasExtensionInUrl) {\n return (this._videoType = mimeType);\n }\n }\n // we check for not supported extensions for URLs that have the extension in the filename\n // e.g. https://vimeo.com/?file=not-supported-extension-video.mkv\n const hasNotSupportedDotExtension = sUrl.match(/\\.(.*)/i);\n if (hasNotSupportedDotExtension) {\n return (this._videoType = null);\n }\n // we check for not supported extensions for URLs that might have the extension as a query parameter\n // e.g. https://youtube.com/?v=3982748927&filetype=mkv\n const hasNotSupportedExtensionInUrl = sUrl.match(\n new RegExp(`(${possibleQueryParameterExtensions.join('|')})=+(.*)&?(?=&|$)`, 'i'),\n );\n if (hasNotSupportedExtensionInUrl) {\n return (this._videoType = null);\n }\n // No extension found, then we assume it's 'mp4' (Match case for '')\n return 'video/mp4';\n }\n // URL was not defined, we return null\n return null;\n }\n\n private async _doHide(exitEl: HTMLButtonElement, duration: number) {\n clearTimeout(this._initial);\n exitEl.style.visibility = 'visible';\n const initial = setTimeout(() => {\n exitEl.style.visibility = 'hidden';\n }, duration);\n return initial;\n }\n private _createEvent(ev: string, playerId: string, msg?: string) {\n const message = msg ? msg : null;\n let event: CustomEvent;\n if (message != null) {\n event = new CustomEvent(`videoPlayer${ev}`, {\n detail: { fromPlayerId: playerId, message: message },\n });\n } else {\n const currentTime: number = this.videoEl ? this.videoEl.currentTime : 0;\n event = new CustomEvent(`videoPlayer${ev}`, {\n detail: { fromPlayerId: playerId, currentTime: currentTime },\n });\n }\n document.dispatchEvent(event);\n }\n private _closeFullscreen() {\n const mydoc: any = document;\n const isInFullScreen: boolean =\n (mydoc.fullscreenElement && mydoc.fullscreenElement !== null) ||\n (mydoc.webkitFullscreenElement && mydoc.webkitFullscreenElement !== null) ||\n (mydoc.mozFullScreenElement && mydoc.mozFullScreenElement !== null) ||\n (mydoc.msFullscreenElement && mydoc.msFullscreenElement !== null);\n if (isInFullScreen) {\n if (mydoc.mozCancelFullScreen) {\n mydoc.mozCancelFullScreen();\n } else if (mydoc.webkitExitFullscreen) {\n mydoc.webkitExitFullscreen();\n } else if (mydoc.msExitFullscreen) {\n mydoc.msExitFullscreen();\n } else if (mydoc.exitFullscreen) {\n mydoc.exitFullscreen();\n }\n }\n }\n}\n"]}
|