@antmedia/web_player 2.11.2 → 2.11.11
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/.github/workflows/publish-release.yml +20 -3
- package/.github/workflows/publish-snapshot.yml +1 -1
- package/dist/browser/web_player.js +176 -117
- package/dist/es/index.d.ts +19 -2
- package/dist/es/{plugin-50e1316e.js → plugin-06260ef3.js} +1 -1
- package/dist/es/{video.es-be70c095.js → video.es-0951ae41.js} +41 -36
- package/dist/es/{videojs-webrtc-plugin-7054aa21.js → videojs-webrtc-plugin-7e293bd2.js} +1 -1
- package/dist/es/{videojs-webrtc-plugin.es-777bf41a.js → videojs-webrtc-plugin.es-0f1490f6.js} +7 -13
- package/dist/es/web_player.js +180 -121
- package/dist/index.d.ts +19 -2
- package/dist/{plugin-bec9dc4a.js → plugin-1270024e.js} +9 -9
- package/dist/{video.es-df9af03d.js → video.es-474303e7.js} +43 -36
- package/dist/{videojs-webrtc-plugin-3becde8c.js → videojs-webrtc-plugin-5dd8808d.js} +1 -1
- package/dist/{videojs-webrtc-plugin.es-ee6d0333.js → videojs-webrtc-plugin.es-812e1a77.js} +28 -34
- package/dist/web_player.js +180 -121
- package/package.json +2 -2
- package/src/web_player.js +197 -136
- package/test/embedded-player.test.js +136 -28
- package/dist/es/videojs-webrtc-plugin-f56e1f9e.js +0 -3
- package/dist/es/videojs-webrtc-plugin.es-2a0dfc29.js +0 -40977
- package/dist/es/videojs-webrtc-plugin.es-333788d9.js +0 -7673
- package/dist/es/videojs-webrtc-plugin.es-9544f6e0.js +0 -7699
- package/dist/videojs-webrtc-plugin-77a9860b.js +0 -5
- package/dist/videojs-webrtc-plugin.es-0787d11e.js +0 -7701
- package/dist/videojs-webrtc-plugin.es-493b195e.js +0 -40979
- package/dist/videojs-webrtc-plugin.es-8f4ea4e4.js +0 -7675
- package/visual.code-workspace +0 -11
package/dist/web_player.js
CHANGED
|
@@ -415,6 +415,10 @@ class WebPlayer {
|
|
|
415
415
|
* It will be taken from url parameter "mute".
|
|
416
416
|
*/
|
|
417
417
|
_defineProperty(this, "mute", false);
|
|
418
|
+
/**
|
|
419
|
+
* controls: Toggles the visibility of player controls.
|
|
420
|
+
*/
|
|
421
|
+
_defineProperty(this, "controls", true);
|
|
418
422
|
/**
|
|
419
423
|
* Force the Player to play with audio Auto Play might not work.
|
|
420
424
|
*/
|
|
@@ -509,6 +513,15 @@ class WebPlayer {
|
|
|
509
513
|
* Is IP Camera
|
|
510
514
|
*/
|
|
511
515
|
_defineProperty(this, "isIPCamera", void 0);
|
|
516
|
+
/**
|
|
517
|
+
* Stream id of backup stream.
|
|
518
|
+
*/
|
|
519
|
+
_defineProperty(this, "backupStreamId", void 0);
|
|
520
|
+
/**
|
|
521
|
+
* activeStreamId: is the stream id that is being played currently
|
|
522
|
+
* It can be streamID or backupStreamId
|
|
523
|
+
*/
|
|
524
|
+
_defineProperty(this, "activeStreamId", void 0);
|
|
512
525
|
WebPlayer.DEFAULT_PLAY_ORDER = ["webrtc", "hls"];
|
|
513
526
|
WebPlayer.DEFAULT_PLAY_TYPE = ["mp4", "webm"];
|
|
514
527
|
WebPlayer.HLS_EXTENSION = "m3u8";
|
|
@@ -521,6 +534,7 @@ class WebPlayer {
|
|
|
521
534
|
WebPlayer.STREAMS_FOLDER = "streams";
|
|
522
535
|
WebPlayer.LL_HLS_Folder = "ll-hls";
|
|
523
536
|
WebPlayer.VIDEO_PLAYER_ID = "video-player";
|
|
537
|
+
WebPlayer.PLAYER_EVENTS = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting', 'enterpictureinpicture', 'leavepictureinpicture', 'fullscreenchange', 'resize', 'audioonlymodechange', 'audiopostermodechange', 'controlsdisabled', 'controlsenabled', 'debugon', 'debugoff', 'disablepictureinpicturechanged', 'dispose', 'enterFullWindow', 'error', 'exitFullWindow', 'firstplay', 'fullscreenerror', 'languagechange', 'loadedmetadata', 'loadstart', 'playerreset', 'playerresize', 'posterchange', 'ready', 'textdata', 'useractive', 'userinactive', 'usingcustomcontrols', 'usingnativecontrols'];
|
|
524
538
|
|
|
525
539
|
// Initialize default values
|
|
526
540
|
this.setDefaults();
|
|
@@ -554,6 +568,8 @@ class WebPlayer {
|
|
|
554
568
|
alert(message);
|
|
555
569
|
throw new Error(message);
|
|
556
570
|
}
|
|
571
|
+
//set the active stream id as stream id
|
|
572
|
+
this.activeStreamId = this.streamId;
|
|
557
573
|
if (!this.httpBaseURL) {
|
|
558
574
|
//this is the case where web player gets everything from url
|
|
559
575
|
var appName = "/";
|
|
@@ -572,17 +588,16 @@ class WebPlayer {
|
|
|
572
588
|
}
|
|
573
589
|
path += appName;
|
|
574
590
|
this.httpBaseURL = this.window.location.protocol + "//" + path;
|
|
575
|
-
this.
|
|
591
|
+
this.websocketBaseURL = "ws://" + path;
|
|
576
592
|
if (this.window.location.protocol.startsWith("https")) {
|
|
577
|
-
this.
|
|
593
|
+
this.websocketBaseURL = this.websocketBaseURL.replace("ws", "wss");
|
|
578
594
|
}
|
|
579
|
-
} else if (!this.
|
|
595
|
+
} else if (!this.websocketBaseURL) {
|
|
580
596
|
//this is the case where web player gets inputs from config object
|
|
581
597
|
if (!this.httpBaseURL.endsWith("/")) {
|
|
582
598
|
this.httpBaseURL += "/";
|
|
583
599
|
}
|
|
584
|
-
this.
|
|
585
|
-
this.websocketURL += this.streamId + ".webrtc";
|
|
600
|
+
this.websocketBaseURL = this.httpBaseURL.replace("http", "ws");
|
|
586
601
|
}
|
|
587
602
|
this.dom = this.window.document;
|
|
588
603
|
this.containerElement.innerHTML = this.videoHTMLContent;
|
|
@@ -640,7 +655,7 @@ class WebPlayer {
|
|
|
640
655
|
this.aScene = null;
|
|
641
656
|
this.playerListener = null;
|
|
642
657
|
this.webRTCDataListener = null;
|
|
643
|
-
this.
|
|
658
|
+
this.websocketBaseURL = null;
|
|
644
659
|
this.httpBaseURL = null;
|
|
645
660
|
this.videoHTMLContent = STATIC_VIDEO_HTML;
|
|
646
661
|
this.videoPlayerId = "video-player";
|
|
@@ -656,6 +671,8 @@ class WebPlayer {
|
|
|
656
671
|
this.ptzMovement = "relative";
|
|
657
672
|
this.restAPIPromise = null;
|
|
658
673
|
this.isIPCamera = false;
|
|
674
|
+
this.playerEvents = WebPlayer.PLAYER_EVENTS;
|
|
675
|
+
this.backupStreamId = null;
|
|
659
676
|
}
|
|
660
677
|
initializeFromUrlParams() {
|
|
661
678
|
var _getUrlParameter;
|
|
@@ -703,15 +720,16 @@ class WebPlayer {
|
|
|
703
720
|
this.restJwt = getUrlParameter_1("restJwt", this.window.location.search) || this.restJwt;
|
|
704
721
|
this.ptzValueStep = getUrlParameter_1("ptzValueStep", this.window.location.search) || this.ptzValueStep;
|
|
705
722
|
this.ptzMovement = getUrlParameter_1("ptzMovement", this.window.location.search) || this.ptzMovement;
|
|
723
|
+
this.backupStreamId = getUrlParameter_1("backupStreamId", this.window.location.search) || this.backupStreamId;
|
|
706
724
|
}
|
|
707
725
|
loadWebRTCComponents() {
|
|
708
726
|
if (this.playOrder.includes("webrtc")) {
|
|
709
|
-
return Promise.resolve().then(function () { return require('./videojs-webrtc-plugin-
|
|
727
|
+
return Promise.resolve().then(function () { return require('./videojs-webrtc-plugin-5dd8808d.js'); }).then(css => {
|
|
710
728
|
Logger_1.info("videojs-webrtc-plugin.css is loaded");
|
|
711
729
|
var styleElement = this.dom.createElement('style');
|
|
712
730
|
styleElement.textContent = css.default.toString(); // Assuming css module exports a string
|
|
713
731
|
this.dom.head.appendChild(styleElement);
|
|
714
|
-
return Promise.resolve().then(function () { return require('./videojs-webrtc-plugin.es-
|
|
732
|
+
return Promise.resolve().then(function () { return require('./videojs-webrtc-plugin.es-812e1a77.js'); }).then(videojsWebrtcPluginLocal => {
|
|
715
733
|
Logger_1.info("videojs-webrtc-plugin is loaded");
|
|
716
734
|
});
|
|
717
735
|
});
|
|
@@ -732,12 +750,12 @@ class WebPlayer {
|
|
|
732
750
|
styleElement.textContent = css.default.toString(); // Assuming css module exports a string
|
|
733
751
|
this.dom.head.appendChild(styleElement);
|
|
734
752
|
}).then(() => {
|
|
735
|
-
return Promise.resolve().then(function () { return require('./video.es-
|
|
753
|
+
return Promise.resolve().then(function () { return require('./video.es-474303e7.js'); }).then(function (n) { return n.video_es; });
|
|
736
754
|
}).then(videojs => {
|
|
737
755
|
window.videojs = videojs.default;
|
|
738
756
|
this.videojsLoaded = true;
|
|
739
757
|
}).then(() => {
|
|
740
|
-
return Promise.resolve().then(function () { return require('./plugin-
|
|
758
|
+
return Promise.resolve().then(function () { return require('./plugin-1270024e.js'); });
|
|
741
759
|
}).then(() => {
|
|
742
760
|
return this.loadWebRTCComponents();
|
|
743
761
|
});
|
|
@@ -851,26 +869,12 @@ class WebPlayer {
|
|
|
851
869
|
limitRenditionByPlayerDimensions: false
|
|
852
870
|
}
|
|
853
871
|
},
|
|
854
|
-
controls:
|
|
872
|
+
controls: this.controls,
|
|
855
873
|
class: 'video-js vjs-default-skin vjs-big-play-centered',
|
|
856
874
|
muted: this.mute,
|
|
857
875
|
preload: "auto",
|
|
858
876
|
autoplay: this.autoPlay
|
|
859
877
|
});
|
|
860
|
-
this.videojsPlayer.on('error', e => {
|
|
861
|
-
Logger_1.warn("There is an error in playback: ", e);
|
|
862
|
-
// We need to add this kind of check. If we don't add this kind of checkpoint, it will create an infinite loop
|
|
863
|
-
if (!this.errorCalled) {
|
|
864
|
-
this.errorCalled = true;
|
|
865
|
-
setTimeout(() => {
|
|
866
|
-
this.tryNextTech();
|
|
867
|
-
this.errorCalled = false;
|
|
868
|
-
}, 2500);
|
|
869
|
-
}
|
|
870
|
-
if (this.playerListener != null) {
|
|
871
|
-
this.playerListener("error", e);
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
878
|
|
|
875
879
|
//webrtc specific events
|
|
876
880
|
if (extension == "webrtc") {
|
|
@@ -892,7 +896,7 @@ class WebPlayer {
|
|
|
892
896
|
* If getting codec incompatible or remote description error, it will redirect HLS player.
|
|
893
897
|
*/
|
|
894
898
|
Logger_1.warn("notSetRemoteDescription error. Redirecting to HLS player.");
|
|
895
|
-
this.playIfExists("hls");
|
|
899
|
+
this.playIfExists("hls", this.activeStreamId);
|
|
896
900
|
}
|
|
897
901
|
if (this.playerListener != null) {
|
|
898
902
|
this.playerListener("webrtc-error", errors);
|
|
@@ -956,72 +960,7 @@ class WebPlayer {
|
|
|
956
960
|
if (extension == "mp4" || extension == "webm" || extension == "m3u8") {
|
|
957
961
|
this.makeVideoJSVisibleWhenReady();
|
|
958
962
|
}
|
|
959
|
-
this.
|
|
960
|
-
//reinit to play after it ends
|
|
961
|
-
Logger_1.warn("stream is ended");
|
|
962
|
-
this.setPlayerVisible(false);
|
|
963
|
-
//for webrtc, this event can be called by two reasons
|
|
964
|
-
//1. ice connection is not established, it means that there is a networking issug
|
|
965
|
-
//2. stream is ended
|
|
966
|
-
if (this.currentPlayType != "vod") {
|
|
967
|
-
//if it's vod, it means that stream is ended and no need to replay
|
|
968
|
-
|
|
969
|
-
if (this.iceConnected) {
|
|
970
|
-
//if iceConnected is true, it means that stream is really ended for webrtc
|
|
971
|
-
|
|
972
|
-
//initialize to play again if the publishing starts again
|
|
973
|
-
this.playIfExists(this.playOrder[0]);
|
|
974
|
-
} else if (this.currentPlayType == "hls") {
|
|
975
|
-
//if it's hls, it means that stream is ended
|
|
976
|
-
|
|
977
|
-
this.setPlayerVisible(false);
|
|
978
|
-
if (this.playOrder[0] = "hls") {
|
|
979
|
-
//do not play again if it's hls because it play last seconds again, let the server clear it
|
|
980
|
-
setTimeout(() => {
|
|
981
|
-
this.playIfExists(this.playOrder[0]);
|
|
982
|
-
}, 10000);
|
|
983
|
-
} else {
|
|
984
|
-
this.playIfExists(this.playOrder[0]);
|
|
985
|
-
}
|
|
986
|
-
//TODO: what if the stream is hls vod then it always re-play
|
|
987
|
-
} else {
|
|
988
|
-
//if iceConnected is false, it means that there is a networking issue for webrtc
|
|
989
|
-
this.tryNextTech();
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
if (this.playerListener != null) {
|
|
993
|
-
this.playerListener("ended");
|
|
994
|
-
}
|
|
995
|
-
});
|
|
996
|
-
|
|
997
|
-
//webrtc plugin sends play event. On the other hand, webrtc plugin sends ready event for every scenario.
|
|
998
|
-
//so no need to trust ready event for webrt play
|
|
999
|
-
this.videojsPlayer.on("play", () => {
|
|
1000
|
-
this.setPlayerVisible(true);
|
|
1001
|
-
if (this.playerListener != null) {
|
|
1002
|
-
this.playerListener("play");
|
|
1003
|
-
}
|
|
1004
|
-
if (this.restJwt) {
|
|
1005
|
-
this.isIpCameraBroadcast();
|
|
1006
|
-
} else if (this.isIPCamera) {
|
|
1007
|
-
this.injectPtzElements();
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
this.videojsPlayer.on("playing", () => {
|
|
1011
|
-
if (this.playerListener != null) {
|
|
1012
|
-
this.playerListener("playing");
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
this.videojsPlayer.on("timeupdate", () => {
|
|
1016
|
-
if (this.playerListener != null) {
|
|
1017
|
-
this.playerListener("timeupdate");
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
this.videojsPlayer.on("pause", () => {
|
|
1021
|
-
if (this.playerListener != null) {
|
|
1022
|
-
this.playerListener("pause");
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
963
|
+
this.listenPlayerEvents();
|
|
1025
964
|
this.iceConnected = false;
|
|
1026
965
|
this.videojsPlayer.src({
|
|
1027
966
|
src: streamUrl,
|
|
@@ -1045,6 +984,109 @@ class WebPlayer {
|
|
|
1045
984
|
});
|
|
1046
985
|
}
|
|
1047
986
|
}
|
|
987
|
+
listenPlayerEvents() {
|
|
988
|
+
this.playerEvents.forEach(event => {
|
|
989
|
+
this.videojsPlayer.on(event, eventData => {
|
|
990
|
+
switch (event) {
|
|
991
|
+
case 'play':
|
|
992
|
+
this.setPlayerVisible(true);
|
|
993
|
+
if (this.playerListener != null) {
|
|
994
|
+
this.playerListener("play");
|
|
995
|
+
}
|
|
996
|
+
if (this.restJwt) {
|
|
997
|
+
this.isIpCameraBroadcast();
|
|
998
|
+
} else if (this.isIPCamera) {
|
|
999
|
+
this.injectPtzElements();
|
|
1000
|
+
}
|
|
1001
|
+
break;
|
|
1002
|
+
case 'ended':
|
|
1003
|
+
//reinit to play after it ends
|
|
1004
|
+
Logger_1.warn("stream is ended");
|
|
1005
|
+
this.setPlayerVisible(false);
|
|
1006
|
+
//for webrtc, this event can be called by two reasons
|
|
1007
|
+
//1. ice connection is not established, it means that there is a networking issug
|
|
1008
|
+
//2. stream is ended
|
|
1009
|
+
if (this.currentPlayType != "vod") {
|
|
1010
|
+
//if it's vod, it means that stream is ended and no need to replay
|
|
1011
|
+
|
|
1012
|
+
if (this.iceConnected) {
|
|
1013
|
+
//if iceConnected is true, it means that stream is really ended for webrtc
|
|
1014
|
+
|
|
1015
|
+
//initialize to play again if the publishing starts again
|
|
1016
|
+
this.playIfExists(this.playOrder[0], this.activeStreamId);
|
|
1017
|
+
} else if (this.currentPlayType == "hls") {
|
|
1018
|
+
//if it's hls, it means that stream is ended
|
|
1019
|
+
|
|
1020
|
+
this.setPlayerVisible(false);
|
|
1021
|
+
if (this.playOrder[0] = "hls") {
|
|
1022
|
+
//do not play again if it's hls because it play last seconds again, let the server clear it
|
|
1023
|
+
setTimeout(() => {
|
|
1024
|
+
this.playIfExists(this.playOrder[0], this.activeStreamId);
|
|
1025
|
+
}, 10000);
|
|
1026
|
+
} else {
|
|
1027
|
+
this.playIfExists(this.playOrder[0], this.activeStreamId);
|
|
1028
|
+
}
|
|
1029
|
+
//TODO: what if the stream is hls vod then it always re-play
|
|
1030
|
+
} else {
|
|
1031
|
+
//if iceConnected is false, it means that there is a networking issue for webrtc
|
|
1032
|
+
this.tryNextTech();
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
if (this.playerListener != null) {
|
|
1036
|
+
this.playerListener(event);
|
|
1037
|
+
}
|
|
1038
|
+
break;
|
|
1039
|
+
case 'timeupdate':
|
|
1040
|
+
if (this.playerListener != null) {
|
|
1041
|
+
this.playerListener(event, eventData, {
|
|
1042
|
+
currentTime: this.videojsPlayer.currentTime()
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
break;
|
|
1046
|
+
case 'progress':
|
|
1047
|
+
if (this.playerListener != null) {
|
|
1048
|
+
this.playerListener(event, eventData, {
|
|
1049
|
+
bufferedPercent: this.videojsPlayer.bufferedPercent()
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
break;
|
|
1053
|
+
case 'volumechange':
|
|
1054
|
+
if (this.playerListener != null) {
|
|
1055
|
+
this.playerListener(event, eventData, {
|
|
1056
|
+
volume: this.videojsPlayer.volume(),
|
|
1057
|
+
muted: this.videojsPlayer.muted()
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
break;
|
|
1061
|
+
case 'ratechange':
|
|
1062
|
+
if (this.playerListener != null) {
|
|
1063
|
+
this.playerListener(event, eventData, {
|
|
1064
|
+
playbackRate: this.videojsPlayer.playbackRate()
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
break;
|
|
1068
|
+
case 'error':
|
|
1069
|
+
Logger_1.warn("There is an error in playback: ", eventData);
|
|
1070
|
+
// We need to add this kind of check. If we don't add this kind of checkpoint, it will create an infinite loop
|
|
1071
|
+
if (!this.errorCalled) {
|
|
1072
|
+
this.errorCalled = true;
|
|
1073
|
+
setTimeout(() => {
|
|
1074
|
+
this.tryNextTech();
|
|
1075
|
+
this.errorCalled = false;
|
|
1076
|
+
}, 2500);
|
|
1077
|
+
}
|
|
1078
|
+
if (this.playerListener != null) {
|
|
1079
|
+
this.playerListener("error", eventData);
|
|
1080
|
+
}
|
|
1081
|
+
break;
|
|
1082
|
+
default:
|
|
1083
|
+
if (this.playerListener != null) {
|
|
1084
|
+
this.playerListener(event, eventData);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1048
1090
|
listenForID3MetaData() {
|
|
1049
1091
|
this.videojsPlayer.textTracks().on('addtrack', e => {
|
|
1050
1092
|
var metadataTrack = Array.from(this.videojsPlayer.textTracks()).find(t => t.label === 'Timed Metadata');
|
|
@@ -1137,15 +1179,26 @@ class WebPlayer {
|
|
|
1137
1179
|
this.destroyDashPlayer();
|
|
1138
1180
|
this.destroyVideoJSPlayer();
|
|
1139
1181
|
this.setPlayerVisible(false);
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1182
|
+
|
|
1183
|
+
//before changing play type, let's check if there is any backup stream
|
|
1184
|
+
var playTypeIndex = this.playOrder.indexOf(this.currentPlayType);
|
|
1185
|
+
if (this.activeStreamId == this.streamId && this.backupStreamId != null) {
|
|
1186
|
+
//update active stream id to backup stream id
|
|
1187
|
+
this.activeStreamId = this.backupStreamId;
|
|
1188
|
+
//don't update playTypeIndex because we're trying backup stream with the same play type
|
|
1143
1189
|
} else {
|
|
1144
|
-
|
|
1190
|
+
//reset the activeStreamId back to streamId
|
|
1191
|
+
this.activeStreamId = this.streamId;
|
|
1192
|
+
//update the playTypeIndex to try next tech
|
|
1193
|
+
if (playTypeIndex == -1 || playTypeIndex == this.playOrder.length - 1) {
|
|
1194
|
+
playTypeIndex = 0;
|
|
1195
|
+
} else {
|
|
1196
|
+
playTypeIndex++;
|
|
1197
|
+
}
|
|
1145
1198
|
}
|
|
1146
1199
|
this.tryNextTechTimer = setTimeout(() => {
|
|
1147
1200
|
this.tryNextTechTimer = -1;
|
|
1148
|
-
this.playIfExists(this.playOrder[
|
|
1201
|
+
this.playIfExists(this.playOrder[playTypeIndex], this.activeStreamId);
|
|
1149
1202
|
}, 3000);
|
|
1150
1203
|
} else {
|
|
1151
1204
|
Logger_1.debug("tryNextTech is already scheduled no need to schedule again");
|
|
@@ -1213,10 +1266,10 @@ class WebPlayer {
|
|
|
1213
1266
|
if (this.playOrder[0] = "dash") {
|
|
1214
1267
|
//do not play again if it's dash because it play last seconds again, let the server clear it
|
|
1215
1268
|
setTimeout(() => {
|
|
1216
|
-
this.playIfExists(this.playOrder[0]);
|
|
1269
|
+
this.playIfExists(this.playOrder[0], this.activeStreamId);
|
|
1217
1270
|
}, 10000);
|
|
1218
1271
|
} else {
|
|
1219
|
-
this.playIfExists(this.playOrder[0]);
|
|
1272
|
+
this.playIfExists(this.playOrder[0], this.activeStreamId);
|
|
1220
1273
|
}
|
|
1221
1274
|
if (this.playerListener != null) {
|
|
1222
1275
|
this.playerListener("ended");
|
|
@@ -1303,7 +1356,7 @@ class WebPlayer {
|
|
|
1303
1356
|
* play the stream with the given tech
|
|
1304
1357
|
* @param {string} tech
|
|
1305
1358
|
*/
|
|
1306
|
-
playIfExists(tech) {
|
|
1359
|
+
playIfExists(tech, streamIdToPlay) {
|
|
1307
1360
|
var _this = this;
|
|
1308
1361
|
return _asyncToGenerator(function* () {
|
|
1309
1362
|
_this.currentPlayType = tech;
|
|
@@ -1311,70 +1364,73 @@ class WebPlayer {
|
|
|
1311
1364
|
_this.destroyDashPlayer();
|
|
1312
1365
|
_this.setPlayerVisible(false);
|
|
1313
1366
|
_this.containerElement.innerHTML = _this.videoHTMLContent;
|
|
1314
|
-
Logger_1.warn("Try to play the stream " +
|
|
1367
|
+
Logger_1.warn("Try to play the stream " + streamIdToPlay + " with " + _this.currentPlayType);
|
|
1315
1368
|
switch (_this.currentPlayType) {
|
|
1316
1369
|
case "hls":
|
|
1317
1370
|
//TODO: Test case for hls
|
|
1318
1371
|
//1. Play stream with adaptive m3u8 for live and VoD
|
|
1319
1372
|
//2. Play stream with m3u8 for live and VoD
|
|
1320
1373
|
//3. if files are not available check nextTech is being called
|
|
1321
|
-
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER,
|
|
1374
|
+
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER, streamIdToPlay, WebPlayer.HLS_EXTENSION).then(streamPath => {
|
|
1322
1375
|
_this.playWithVideoJS(streamPath, WebPlayer.HLS_EXTENSION);
|
|
1323
1376
|
Logger_1.warn("incoming stream path: " + streamPath);
|
|
1324
1377
|
}).catch(error => {
|
|
1325
|
-
Logger_1.warn("HLS stream resource not available for stream:" +
|
|
1378
|
+
Logger_1.warn("HLS stream resource not available for stream:" + streamIdToPlay + " error is " + error + ". Try next play tech");
|
|
1326
1379
|
_this.tryNextTech();
|
|
1327
1380
|
});
|
|
1328
1381
|
case "ll-hls":
|
|
1329
|
-
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER + "/" + WebPlayer.LL_HLS_FOLDER,
|
|
1382
|
+
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER + "/" + WebPlayer.LL_HLS_FOLDER, streamIdToPlay, WebPlayer.HLS_EXTENSION).then(streamPath => {
|
|
1330
1383
|
_this.playWithVideoJS(streamPath, WebPlayer.HLS_EXTENSION);
|
|
1331
1384
|
Logger_1.warn("incoming stream path: " + streamPath);
|
|
1332
1385
|
}).catch(error => {
|
|
1333
|
-
Logger_1.warn("LL-HLS stream resource not available for stream:" +
|
|
1386
|
+
Logger_1.warn("LL-HLS stream resource not available for stream:" + streamIdToPlay + " error is " + error + ". Try next play tech");
|
|
1334
1387
|
_this.tryNextTech();
|
|
1335
1388
|
});
|
|
1336
1389
|
case "dash":
|
|
1337
|
-
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER,
|
|
1390
|
+
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER, streamIdToPlay + "/" + streamIdToPlay, WebPlayer.DASH_EXTENSION).then(streamPath => {
|
|
1338
1391
|
_this.playViaDash(streamPath);
|
|
1339
1392
|
}).catch(error => {
|
|
1340
|
-
Logger_1.warn("DASH stream resource not available for stream:" +
|
|
1393
|
+
Logger_1.warn("DASH stream resource not available for stream:" + streamIdToPlay + " error is " + error + ". Try next play tech");
|
|
1341
1394
|
_this.tryNextTech();
|
|
1342
1395
|
});
|
|
1343
1396
|
case "webrtc":
|
|
1344
|
-
return _this.playWithVideoJS(_this.addSecurityParams(_this.
|
|
1397
|
+
return _this.playWithVideoJS(_this.addSecurityParams(_this.getWebsocketURLForStream(streamIdToPlay)), WebPlayer.WEBRTC_EXTENSION);
|
|
1345
1398
|
case "vod":
|
|
1346
1399
|
//TODO: Test case for vod
|
|
1347
1400
|
//1. Play stream with mp4 for VoD
|
|
1348
1401
|
//2. Play stream with webm for VoD
|
|
1349
1402
|
//3. Play stream with playOrder type
|
|
1350
1403
|
|
|
1351
|
-
var lastIndexOfDot =
|
|
1404
|
+
var lastIndexOfDot = streamIdToPlay.lastIndexOf(".");
|
|
1352
1405
|
var extension;
|
|
1353
1406
|
if (lastIndexOfDot != -1) {
|
|
1354
1407
|
//if there is a dot in the streamId, it means that this is extension, use it. make the extension empty
|
|
1355
1408
|
_this.playType[0] = "";
|
|
1356
|
-
extension =
|
|
1409
|
+
extension = streamIdToPlay.substring(lastIndexOfDot + 1);
|
|
1357
1410
|
} else {
|
|
1358
1411
|
//we need to give extension to playWithVideoJS
|
|
1359
1412
|
extension = _this.playType[0];
|
|
1360
1413
|
}
|
|
1361
|
-
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER,
|
|
1414
|
+
return _this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER, streamIdToPlay, _this.playType[0]).then(streamPath => {
|
|
1362
1415
|
//we need to give extension to playWithVideoJS
|
|
1363
1416
|
_this.playWithVideoJS(streamPath, extension);
|
|
1364
1417
|
}).catch(error => {
|
|
1365
|
-
Logger_1.warn("VOD stream resource not available for stream:" +
|
|
1418
|
+
Logger_1.warn("VOD stream resource not available for stream:" + streamIdToPlay + " and play type " + _this.playType[0] + ". Error is " + error);
|
|
1366
1419
|
if (_this.playType.length > 1) {
|
|
1367
1420
|
Logger_1.warn("Try next play type which is " + _this.playType[1] + ".");
|
|
1368
|
-
_this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER,
|
|
1421
|
+
_this.checkStreamExistsViaHttp(WebPlayer.STREAMS_FOLDER, streamIdToPlay, _this.playType[1]).then(streamPath => {
|
|
1369
1422
|
_this.playWithVideoJS(streamPath, _this.playType[1]);
|
|
1370
1423
|
}).catch(error => {
|
|
1371
|
-
Logger_1.warn("VOD stream resource not available for stream:" +
|
|
1424
|
+
Logger_1.warn("VOD stream resource not available for stream:" + streamIdToPlay + " and play type error is " + error);
|
|
1372
1425
|
});
|
|
1373
1426
|
}
|
|
1374
1427
|
});
|
|
1375
1428
|
}
|
|
1376
1429
|
})();
|
|
1377
1430
|
}
|
|
1431
|
+
getWebsocketURLForStream(streamIdToPlay) {
|
|
1432
|
+
return this.websocketBaseURL + streamIdToPlay + ".webrtc";
|
|
1433
|
+
}
|
|
1378
1434
|
|
|
1379
1435
|
/**
|
|
1380
1436
|
*
|
|
@@ -1398,10 +1454,12 @@ class WebPlayer {
|
|
|
1398
1454
|
* play the stream with videojs player or dash player
|
|
1399
1455
|
*/
|
|
1400
1456
|
play() {
|
|
1401
|
-
if
|
|
1457
|
+
//if there is a request to play, try original stream first
|
|
1458
|
+
this.activeStreamId = this.streamId;
|
|
1459
|
+
if (this.activeStreamId.startsWith(WebPlayer.STREAMS_FOLDER)) {
|
|
1402
1460
|
//start videojs player because it directly try to play stream from streams folder
|
|
1403
|
-
var lastIndexOfDot = this.
|
|
1404
|
-
var extension = this.
|
|
1461
|
+
var lastIndexOfDot = this.activeStreamId.lastIndexOf(".");
|
|
1462
|
+
var extension = this.activeStreamId.substring(lastIndexOfDot + 1);
|
|
1405
1463
|
this.playOrder = ["vod"];
|
|
1406
1464
|
this.currentPlayType = this.playOrder[0];
|
|
1407
1465
|
if (!this.httpBaseURL.endsWith("/")) {
|
|
@@ -1409,12 +1467,12 @@ class WebPlayer {
|
|
|
1409
1467
|
}
|
|
1410
1468
|
this.containerElement.innerHTML = this.videoHTMLContent;
|
|
1411
1469
|
if (extension == WebPlayer.DASH_EXTENSION) {
|
|
1412
|
-
this.playViaDash(this.httpBaseURL + this.addSecurityParams(this.
|
|
1470
|
+
this.playViaDash(this.httpBaseURL + this.addSecurityParams(this.activeStreamId), extension);
|
|
1413
1471
|
} else {
|
|
1414
|
-
this.playWithVideoJS(this.httpBaseURL + this.addSecurityParams(this.
|
|
1472
|
+
this.playWithVideoJS(this.httpBaseURL + this.addSecurityParams(this.activeStreamId), extension);
|
|
1415
1473
|
}
|
|
1416
1474
|
} else {
|
|
1417
|
-
this.playIfExists(this.playOrder[0]);
|
|
1475
|
+
this.playIfExists(this.playOrder[0], this.activeStreamId);
|
|
1418
1476
|
}
|
|
1419
1477
|
}
|
|
1420
1478
|
|
|
@@ -1478,7 +1536,7 @@ class WebPlayer {
|
|
|
1478
1536
|
return false;
|
|
1479
1537
|
}
|
|
1480
1538
|
injectPtzElements() {
|
|
1481
|
-
var ptzControlsHtmlContent = "\n <style>\n .ptz-camera-container {\n display: none;\n position: absolute;\n flex-direction: row;\n align-items: center;\n bottom: 30px;\n right: 10px;\n z-index:999;\n }\n .direction-arrow-container {\n display: flex;\n width: 200px;\n height: 200px;\n position: relative;\n }\n \n </style>\n <div id=\"ptz-camera-container\" class=\"ptz-camera-container\">\n \n <div style=\"display: flex; flex-direction: column;\">\n <div style=\"margin-bottom:5px\">\n <span id=\"zoom-out-button\" style=\"color: #bc1b22; font-size: 50px; font-weight: bold; user-select: none; cursor: pointer; margin-right: 5px;\">-</span>\n <span id=\"zoom-in-button\" style=\"color: #bc1b22; font-size: 50px; font-weight: bold; cursor: pointer; margin-left: 5px; user-select: none;\">+</span>\n </div>\n <div id=\"direction-arrow-container\" class=\"direction-arrow-container\">\n <img id=\"up-button\" style=\"position: absolute; width: 50px; cursor: pointer; height: 50px; left: 50%; transform: translateX(-50%);\" src=\"" + img + "\"/>\n \n <img id=\"left-button\" style=\"position: absolute; left: 0px; width: 50px; height: 50px; cursor: pointer; top: 50%; transform: translateY(-50%) rotate(-90deg);\" src=\"" + img + "\"/>\n <img id=\"right-button\" style=\"position: absolute; right:0px; top: 50%; width: 50px; cursor: pointer; height: 50px; transform: translateY(-50%) rotate(90deg);\" src=\"" + img + "\"/>\n <img id=\"down-button\" style=\"position: absolute; bottom:0px;left: 50%; width: 50px; cursor: pointer; height: 50px; transform: translateX(-50%) rotate(180deg);\" src=\"" + img + "\"/>\n \n </div>\n \n \n </div>\n </div>\n </div>\n ";
|
|
1539
|
+
var ptzControlsHtmlContent = "\n <style>\n .ptz-camera-container {\n display: none;\n position: absolute;\n flex-direction: row;\n align-items: center;\n bottom: 30px;\n right: 10px;\n z-index:999;\n }\n .direction-arrow-container {\n display: flex;\n width: 200px;\n height: 200px;\n position: relative;\n }\n \n </style>\n <div id=\"ptz-camera-container\" class=\"ptz-camera-container\">\n \n <div style=\"display: flex; flex-direction: column;\">\n <div style=\"margin-bottom:5px\">\n <span id=\"zoom-out-button\" style=\"color: #bc1b22; font-size: 50px; font-weight: bold; user-select: none; cursor: pointer; margin-right: 5px;\">-</span>\n <span id=\"zoom-in-button\" style=\"color: #bc1b22; font-size: 50px; font-weight: bold; cursor: pointer; margin-left: 5px; user-select: none;\">+</span>\n </div>\n <div id=\"direction-arrow-container\" class=\"direction-arrow-container\">\n <img id=\"up-button\" style=\"position: absolute; width: 50px; cursor: pointer; height: 50px; left: 50%; transform: translateX(-50%);\" src=\"" + img.src + "\"/>\n \n <img id=\"left-button\" style=\"position: absolute; left: 0px; width: 50px; height: 50px; cursor: pointer; top: 50%; transform: translateY(-50%) rotate(-90deg);\" src=\"" + img.src + "\"/>\n <img id=\"right-button\" style=\"position: absolute; right:0px; top: 50%; width: 50px; cursor: pointer; height: 50px; transform: translateY(-50%) rotate(90deg);\" src=\"" + img.src + "\"/>\n <img id=\"down-button\" style=\"position: absolute; bottom:0px;left: 50%; width: 50px; cursor: pointer; height: 50px; transform: translateX(-50%) rotate(180deg);\" src=\"" + img.src + "\"/>\n \n </div>\n \n \n </div>\n </div>\n </div>\n ";
|
|
1482
1540
|
var ptzCameraContainer = document.getElementById("ptz-camera-container");
|
|
1483
1541
|
if (ptzCameraContainer) {
|
|
1484
1542
|
Logger_1.info("PTZ controls are already injected");
|
|
@@ -1605,6 +1663,7 @@ class WebPlayer {
|
|
|
1605
1663
|
}
|
|
1606
1664
|
}
|
|
1607
1665
|
}
|
|
1666
|
+
_defineProperty(WebPlayer, "PLAYER_EVENTS", ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting', 'enterpictureinpicture', 'leavepictureinpicture', 'fullscreenchange', 'resize', 'audioonlymodechange', 'audiopostermodechange', 'controlsdisabled', 'controlsenabled', 'debugon', 'debugoff', 'disablepictureinpicturechanged', 'dispose', 'enterFullWindow', 'error', 'exitFullWindow', 'firstplay', 'fullscreenerror', 'languagechange', 'loadedmetadata', 'loadstart', 'playerreset', 'playerresize', 'posterchange', 'ready', 'textdata', 'useractive', 'userinactive', 'usingcustomcontrols', 'usingnativecontrols']);
|
|
1608
1667
|
_defineProperty(WebPlayer, "DEFAULT_PLAY_ORDER", ["webrtc", "hls"]);
|
|
1609
1668
|
_defineProperty(WebPlayer, "DEFAULT_PLAY_TYPE", ["mp4", "webm"]);
|
|
1610
1669
|
_defineProperty(WebPlayer, "HLS_EXTENSION", "m3u8");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antmedia/web_player",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.11",
|
|
4
4
|
"description": "Ant Media Server Player that can play WebRTC, HLS, DASH",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "ISC",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@antmedia/videojs-webrtc-plugin": "^1.3.
|
|
32
|
+
"@antmedia/videojs-webrtc-plugin": "^1.3.2",
|
|
33
33
|
"@antmedia/webrtc_adaptor": "^2.11.3",
|
|
34
34
|
"@rollup/plugin-json": "6.1.0",
|
|
35
35
|
"aframe": "1.5.0",
|