@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
|
@@ -22,7 +22,7 @@ describe("WebPlayer", function() {
|
|
|
22
22
|
sandbox.restore();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
it("
|
|
25
|
+
it("check-default-parameters", async function() {
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
var videoContainer = document.createElement("video_container");
|
|
@@ -79,10 +79,10 @@ describe("WebPlayer", function() {
|
|
|
79
79
|
|
|
80
80
|
var player = new WebPlayer(windowComponent, videoContainer, placeHolder);
|
|
81
81
|
|
|
82
|
-
expect(player.
|
|
82
|
+
expect(player.websocketBaseURL).to.be.equal('wss://example.com/');
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
it("
|
|
85
|
+
it("check-url-parameters", async function() {
|
|
86
86
|
|
|
87
87
|
var videoContainer = document.createElement("video_container");
|
|
88
88
|
|
|
@@ -119,7 +119,9 @@ describe("WebPlayer", function() {
|
|
|
119
119
|
expect(player.iceConnected).to.false;
|
|
120
120
|
expect(player.errorCalled).to.false;
|
|
121
121
|
|
|
122
|
-
expect(player.
|
|
122
|
+
expect(player.websocketBaseURL).to.be.equal('ws://example.com/');
|
|
123
|
+
var fullWebSocketBaseUrl = player.getWebsocketURLForStream(player.streamId);
|
|
124
|
+
expect(fullWebSocketBaseUrl).to.be.equal('ws://example.com/stream123.webrtc');
|
|
123
125
|
expect(player.httpBaseURL).to.be.equal('http://example.com/');
|
|
124
126
|
expect(player.getSecurityQueryParams()).to.be.equal("&token="+token+"&subscriberId="+subscriberId+"&subscriberCode="+subscriberCode);
|
|
125
127
|
|
|
@@ -135,14 +137,14 @@ describe("WebPlayer", function() {
|
|
|
135
137
|
|
|
136
138
|
player = new WebPlayer(windowComponent, videoContainer, placeHolder);
|
|
137
139
|
|
|
138
|
-
expect(player.
|
|
140
|
+
expect(player.websocketBaseURL).to.be.equal('ws://example.com/');
|
|
139
141
|
expect(player.httpBaseURL).to.be.equal('http://example.com/');
|
|
140
142
|
|
|
141
143
|
|
|
142
144
|
}
|
|
143
145
|
});
|
|
144
146
|
|
|
145
|
-
it("
|
|
147
|
+
it("check-config-parameters", async function(){
|
|
146
148
|
|
|
147
149
|
var videoContainer = document.createElement("video_container");
|
|
148
150
|
|
|
@@ -209,7 +211,9 @@ describe("WebPlayer", function() {
|
|
|
209
211
|
|
|
210
212
|
expect(player.httpBaseURL).to.be.equal('http://example.antmedia.io:5080/WebRTCAppEE/');
|
|
211
213
|
|
|
212
|
-
expect(player.
|
|
214
|
+
expect(player.websocketBaseURL).to.be.equal('ws://example.antmedia.io:5080/WebRTCAppEE/');
|
|
215
|
+
var fullWebSocketUrl = player.getWebsocketURLForStream(player.streamId);
|
|
216
|
+
expect(fullWebSocketUrl).to.be.equal('ws://example.antmedia.io:5080/WebRTCAppEE/streamConfig123.webrtc');
|
|
213
217
|
|
|
214
218
|
});
|
|
215
219
|
|
|
@@ -421,7 +425,7 @@ describe("WebPlayer", function() {
|
|
|
421
425
|
|
|
422
426
|
var placeHolder = document.createElement("place_holder");
|
|
423
427
|
|
|
424
|
-
var locationComponent = { href : 'http://example.com?id=stream123', search: "?id=stream123", pathname:"/" , protocol:"http:"};
|
|
428
|
+
var locationComponent = { href : 'http://example.com?id=stream123&backupStreamId=backup123', search: "?id=stream123&backupStreamId=backup123", pathname:"/" , protocol:"http:"};
|
|
425
429
|
var windowComponent = { location : locationComponent,
|
|
426
430
|
document: document};
|
|
427
431
|
|
|
@@ -435,30 +439,63 @@ describe("WebPlayer", function() {
|
|
|
435
439
|
player.playOrder = ["webrtc","hls"];
|
|
436
440
|
player.currentPlayType = "webrtc";
|
|
437
441
|
|
|
442
|
+
expect(player.streamId).to.be.equal("stream123");
|
|
443
|
+
expect(player.backupStreamId).to.be.equal("backup123");
|
|
444
|
+
|
|
438
445
|
player.tryNextTech();
|
|
439
446
|
|
|
440
|
-
|
|
441
|
-
|
|
442
447
|
expect(destroyDashPlayer.calledOnce).to.be.true;
|
|
443
448
|
expect(destroyVideoJSPlayer.calledOnce).to.be.true;
|
|
444
449
|
expect(setPlayerVisible.calledOnce).to.be.true;
|
|
445
|
-
|
|
450
|
+
expect(setPlayerVisible.calledWithMatch(false)).to.be.true;
|
|
446
451
|
|
|
447
452
|
clock.tick(2500);
|
|
448
453
|
|
|
449
454
|
expect(playIfExists.calledOnce).to.be.false;
|
|
450
455
|
|
|
451
|
-
clock.tick(
|
|
452
|
-
|
|
456
|
+
clock.tick(1500);
|
|
457
|
+
//4 seconds passed
|
|
458
|
+
|
|
459
|
+
|
|
453
460
|
expect(playIfExists.calledOnce).to.be.true;
|
|
454
|
-
|
|
461
|
+
//it should call with webrtc, backup stream
|
|
462
|
+
expect(playIfExists.calledWithMatch("webrtc", "backup123")).to.be.true;
|
|
463
|
+
|
|
464
|
+
player.currentPlayType = "webrtc";
|
|
465
|
+
|
|
466
|
+
player.tryNextTech();
|
|
467
|
+
|
|
468
|
+
clock.tick(3500);
|
|
469
|
+
|
|
470
|
+
expect(playIfExists.callCount).to.be.equal(2);
|
|
471
|
+
//it should call with other tech hls and original stream
|
|
472
|
+
expect(playIfExists.calledWithMatch("hls", "stream123")).to.be.true;
|
|
455
473
|
|
|
474
|
+
|
|
475
|
+
player.currentPlayType = "hls";
|
|
476
|
+
|
|
477
|
+
player.tryNextTech();
|
|
478
|
+
|
|
479
|
+
clock.tick(3500);
|
|
480
|
+
expect(playIfExists.callCount).to.be.equal(3);
|
|
481
|
+
//it should call with hls and backup stream
|
|
482
|
+
expect(playIfExists.calledWithMatch("hls", "backup123")).to.be.true;
|
|
483
|
+
|
|
484
|
+
|
|
456
485
|
player.currentPlayType = "hls";
|
|
457
486
|
|
|
458
487
|
player.tryNextTech();
|
|
459
488
|
clock.tick(3500);
|
|
460
|
-
expect(playIfExists.callCount).to.be.equal(
|
|
461
|
-
|
|
489
|
+
expect(playIfExists.callCount).to.be.equal(4);
|
|
490
|
+
//it should call with webrtc and original stream again
|
|
491
|
+
expect(playIfExists.calledWithMatch("webrtc", "stream123")).to.be.true;
|
|
492
|
+
|
|
493
|
+
player.currentPlayType = "hls";
|
|
494
|
+
player.tryNextTech();
|
|
495
|
+
clock.tick(3500);
|
|
496
|
+
expect(playIfExists.callCount).to.be.equal(5);
|
|
497
|
+
//it should call with webrtc and backup stream
|
|
498
|
+
expect(playIfExists.calledWithMatch("webrtc", "backup123")).to.be.true;
|
|
462
499
|
|
|
463
500
|
});
|
|
464
501
|
|
|
@@ -596,8 +633,9 @@ describe("WebPlayer", function() {
|
|
|
596
633
|
var videoContainer = document.createElement("video_container");
|
|
597
634
|
|
|
598
635
|
var placeHolder = document.createElement("place_holder");
|
|
599
|
-
|
|
600
|
-
var
|
|
636
|
+
|
|
637
|
+
var streamId = "stream123";
|
|
638
|
+
var locationComponent = { href : 'http://example.com?id=stream123', search: "?id="+streamId, pathname: "/",
|
|
601
639
|
hostname:"example.com", port:5080,
|
|
602
640
|
protocol:"http:" };
|
|
603
641
|
var windowComponent = { location : locationComponent,
|
|
@@ -608,7 +646,7 @@ describe("WebPlayer", function() {
|
|
|
608
646
|
var player = new WebPlayer(windowComponent, videoContainer, placeHolder);
|
|
609
647
|
var playWithVideoJS = sinon.replace(player, "playWithVideoJS", sinon.fake());
|
|
610
648
|
|
|
611
|
-
await player.playIfExists("webrtc");
|
|
649
|
+
await player.playIfExists("webrtc", streamId);
|
|
612
650
|
expect(playWithVideoJS.callCount).to.be.equal(1);
|
|
613
651
|
expect(playWithVideoJS.calledWithExactly("ws://example.com:5080/stream123.webrtc", "webrtc")).to.be.true;
|
|
614
652
|
|
|
@@ -640,7 +678,7 @@ describe("WebPlayer", function() {
|
|
|
640
678
|
expect(setPlayerVisible.called).to.be.true;
|
|
641
679
|
expect(setPlayerVisible.calledWithMatch(false)).to.be.true;
|
|
642
680
|
|
|
643
|
-
await player.playIfExists("webrtc");
|
|
681
|
+
await player.playIfExists("webrtc", player.streamId);
|
|
644
682
|
expect(playWithVideoJS.callCount).to.be.equal(2);
|
|
645
683
|
expect(playWithVideoJS.calledWithMatch("ws://example.com:5080/stream123.webrtc", "webrtc")).to.be.true;
|
|
646
684
|
|
|
@@ -648,7 +686,7 @@ describe("WebPlayer", function() {
|
|
|
648
686
|
|
|
649
687
|
var playWithVideoJS = sinon.replace(player, "playWithVideoJS", sinon.fake());
|
|
650
688
|
sinon.replace(player, "checkStreamExistsViaHttp", sinon.fake.returns(Promise.resolve("streams/stream123.mp4")));
|
|
651
|
-
await player.playIfExists("vod");
|
|
689
|
+
await player.playIfExists("vod", player.streamId);
|
|
652
690
|
|
|
653
691
|
expect(playWithVideoJS.callCount).to.be.equal(1);
|
|
654
692
|
expect(playWithVideoJS.calledWithMatch("streams/stream123.mp4", "mp4")).to.be.true;
|
|
@@ -658,7 +696,7 @@ describe("WebPlayer", function() {
|
|
|
658
696
|
var playViaDash = sinon.replace(player, "playViaDash", sinon.fake());
|
|
659
697
|
sinon.replace(player, "checkStreamExistsViaHttp", sinon.fake.returns(Promise.resolve("streams/stream123/stream123.mpd")));
|
|
660
698
|
|
|
661
|
-
await player.playIfExists("dash");
|
|
699
|
+
await player.playIfExists("dash", player.streamId);
|
|
662
700
|
expect(playViaDash.callCount).to.be.equal(1);
|
|
663
701
|
expect(playViaDash.calledWithMatch("streams/stream123/stream123.mpd")).to.be.true;
|
|
664
702
|
|
|
@@ -669,14 +707,14 @@ describe("WebPlayer", function() {
|
|
|
669
707
|
sinon.replace(player, "checkStreamExistsViaHttp", sinon.fake.returns(Promise.reject("")));
|
|
670
708
|
var playWithVideoJS = sinon.replace(player, "playWithVideoJS", sinon.fake());
|
|
671
709
|
|
|
672
|
-
await player.playIfExists("hls");
|
|
710
|
+
await player.playIfExists("hls", player.streamId);
|
|
673
711
|
expect(tryNextTech.callCount).to.be.equal(1);
|
|
674
712
|
|
|
675
713
|
|
|
676
|
-
await player.playIfExists("dash");
|
|
714
|
+
await player.playIfExists("dash", player.streamId);
|
|
677
715
|
expect(tryNextTech.callCount).to.be.equal(2);
|
|
678
716
|
|
|
679
|
-
await player.playIfExists("vod");
|
|
717
|
+
await player.playIfExists("vod", player.streamId);
|
|
680
718
|
//because it will not tryNextTech if promises fails
|
|
681
719
|
expect(tryNextTech.callCount).to.be.equal(2);
|
|
682
720
|
|
|
@@ -701,7 +739,7 @@ describe("WebPlayer", function() {
|
|
|
701
739
|
var checkStreamExistsViaHttp = sinon.replace(player, "checkStreamExistsViaHttp", sinon.fake.returns(Promise.resolve("streams/stream123.mp4")));
|
|
702
740
|
var playWithVideoJS = sinon.replace(player, "playWithVideoJS", sinon.fake());
|
|
703
741
|
|
|
704
|
-
await player.playIfExists("vod");
|
|
742
|
+
await player.playIfExists("vod", player.streamId);
|
|
705
743
|
|
|
706
744
|
expect(checkStreamExistsViaHttp.calledWithMatch(WebPlayer.STREAMS_FOLDER, "stream123.mp4", "")).to.be.true;
|
|
707
745
|
expect(playWithVideoJS.calledWithMatch("streams/stream123.mp4", "mp4")).to.be.true;
|
|
@@ -718,7 +756,7 @@ describe("WebPlayer", function() {
|
|
|
718
756
|
checkStreamExistsViaHttp = sinon.replace(player2, "checkStreamExistsViaHttp", sinon.fake.returns(Promise.resolve("")));
|
|
719
757
|
expect(player2.playType[0]).to.be.equal("mp4");
|
|
720
758
|
|
|
721
|
-
player2.playIfExists("vod");
|
|
759
|
+
player2.playIfExists("vod", player2.streamId);
|
|
722
760
|
|
|
723
761
|
expect(checkStreamExistsViaHttp.calledWithMatch(WebPlayer.STREAMS_FOLDER, "stream123", "mp4")).to.be.true;
|
|
724
762
|
|
|
@@ -1026,13 +1064,83 @@ describe("WebPlayer", function() {
|
|
|
1026
1064
|
var checkStreamExistsViaHttp = sinon.replace(player, "checkStreamExistsViaHttp", sinon.fake.resolves(streamPath));
|
|
1027
1065
|
var playWithVideoJS = sinon.replace(player, "playWithVideoJS", sinon.fake());
|
|
1028
1066
|
|
|
1029
|
-
await player.playIfExists("ll-hls");
|
|
1067
|
+
await player.playIfExists("ll-hls", streamId);
|
|
1030
1068
|
|
|
1031
1069
|
expect(checkStreamExistsViaHttp.calledWithMatch(WebPlayer.STREAMS_FOLDER + "/" + WebPlayer.LL_HLS_FOLDER, streamId, WebPlayer.HLS_EXTENSION)).to.be.true;
|
|
1032
1070
|
expect(playWithVideoJS.calledWithMatch(streamPath, WebPlayer.HLS_EXTENSION)).to.be.true;
|
|
1033
1071
|
});
|
|
1034
1072
|
|
|
1073
|
+
it("Player events", async function() {
|
|
1074
|
+
this.timeout(10000)
|
|
1075
|
+
var videoContainer = document.createElement("video_container");
|
|
1076
|
+
|
|
1077
|
+
var placeHolder = document.createElement("place_holder");
|
|
1078
|
+
|
|
1079
|
+
var locationComponent = { href : 'http://example.com?id=stream123', search: "?id=stream123", protocol:"http:", pathname: "/", hostname:"example.com", port:5080 };
|
|
1080
|
+
var windowComponent = { location : locationComponent,
|
|
1081
|
+
document: document,
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
var player = new WebPlayer(windowComponent, videoContainer, placeHolder);
|
|
1085
|
+
|
|
1086
|
+
var setPlayerVisible = sinon.replace(player, "setPlayerVisible", sinon.fake());
|
|
1087
|
+
|
|
1088
|
+
// Mock videojsPlayer
|
|
1089
|
+
player.videojsPlayer = {
|
|
1090
|
+
on: sinon.stub(),
|
|
1091
|
+
currentTime: sinon.stub().returns(10),
|
|
1092
|
+
bufferedPercent: sinon.stub().returns(0.5),
|
|
1093
|
+
volume: sinon.stub().returns(0.8),
|
|
1094
|
+
muted: sinon.stub().returns(false),
|
|
1095
|
+
playbackRate: sinon.stub().returns(1.0),
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
player.playerListener = sinon.stub();
|
|
1099
|
+
|
|
1100
|
+
player.tryNextTech = sinon.stub();
|
|
1101
|
+
|
|
1102
|
+
player.listenPlayerEvents();
|
|
1103
|
+
|
|
1104
|
+
player.playerEvents.forEach(event => {
|
|
1105
|
+
expect(player.videojsPlayer.on.calledWith(event)).to.be.true;
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
const playCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'play')[1];
|
|
1109
|
+
playCallback();
|
|
1110
|
+
expect(setPlayerVisible.calledWith(true)).to.be.true;
|
|
1111
|
+
expect(player.playerListener.calledWith("play")).to.be.true;
|
|
1112
|
+
|
|
1113
|
+
const endedCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'ended')[1];
|
|
1114
|
+
endedCallback();
|
|
1115
|
+
expect(setPlayerVisible.calledWith(false)).to.be.true;
|
|
1116
|
+
expect(player.playerListener.calledWith("ended")).to.be.true;
|
|
1117
|
+
|
|
1118
|
+
const pauseCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'pause')[1];
|
|
1119
|
+
pauseCallback();
|
|
1120
|
+
expect(player.playerListener.calledWith("pause")).to.be.true;
|
|
1121
|
+
|
|
1122
|
+
const errorCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'error')[1];
|
|
1123
|
+
const errorEventData = { code: 4 };
|
|
1124
|
+
errorCallback(errorEventData);
|
|
1125
|
+
expect(player.playerListener.calledWith("error", errorEventData)).to.be.true;
|
|
1126
|
+
|
|
1127
|
+
const timeUpdateCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'timeupdate')[1];
|
|
1128
|
+
timeUpdateCallback();
|
|
1129
|
+
expect(player.playerListener.calledWith('timeupdate', sinon.match.any, { currentTime: 10 })).to.be.true;
|
|
1130
|
+
|
|
1131
|
+
const progressCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'progress')[1];
|
|
1132
|
+
progressCallback();
|
|
1133
|
+
expect(player.playerListener.calledWith('progress', sinon.match.any, { bufferedPercent: 0.5 })).to.be.true;
|
|
1035
1134
|
|
|
1135
|
+
const volumeChangeCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'volumechange')[1];
|
|
1136
|
+
volumeChangeCallback();
|
|
1137
|
+
expect(player.playerListener.calledWith('volumechange', sinon.match.any, { volume: 0.8, muted: false })).to.be.true;
|
|
1138
|
+
|
|
1139
|
+
const rateChangeCallback = player.videojsPlayer.on.args.find(arg => arg[0] === 'ratechange')[1];
|
|
1140
|
+
rateChangeCallback();
|
|
1141
|
+
expect(player.playerListener.calledWith('ratechange', sinon.match.any, { playbackRate: 1.0 })).to.be.true;
|
|
1142
|
+
|
|
1143
|
+
})
|
|
1036
1144
|
|
|
1037
1145
|
|
|
1038
1146
|
});
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var videojsWebrtcPlugin = "/*! @name @antmedia/videojs-webrtc-plugin @version 1.3.1 @license MIT */\n.vjs-custom-spinner{position:absolute;top:50%;transform:translateY(-50%) translateX(-50%);left:50%;width:80px;height:80px}.vjs-custom-spinner:after{content:\" \";display:block;width:64px;height:64px;margin:8px;border-radius:50%;border:6px solid #fff;border-color:#fff transparent;animation:vjs-spinner-spin 1.1s cubic-bezier(.6,.2,0,.8) infinite,vjs-spinner-fade 1.1s linear infinite}";
|
|
2
|
-
|
|
3
|
-
export { videojsWebrtcPlugin as default };
|