@antmedia/web_player 2.12.0 → 2.12.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.
@@ -520,6 +520,24 @@ class WebPlayer {
520
520
  * It can be streamID or backupStreamId
521
521
  */
522
522
  _defineProperty(this, "activeStreamId", void 0);
523
+ // we define insertSecurityParameters in this way because we want to get the this context such as this.subscriberId
524
+ _defineProperty(this, "insertSecurityParameters", options => {
525
+ var queryParams = [];
526
+ if (!options.uri.includes("subscriberId") && this.subscriberId != null) {
527
+ queryParams.push("subscriberId=".concat(this.subscriberId));
528
+ }
529
+ if (!options.uri.includes("subscriberCode") && this.subscriberCode != null) {
530
+ queryParams.push("subscriberCode=".concat(this.subscriberCode));
531
+ }
532
+ if (!options.uri.includes("token") && this.token != null) {
533
+ queryParams.push("token=".concat(this.token));
534
+ }
535
+ if (queryParams.length > 0) {
536
+ var queryString = queryParams.join("&");
537
+ options.uri += options.uri.includes("?") ? "&".concat(queryString) : "?".concat(queryString);
538
+ }
539
+ Logger_1.debug("hls request: " + options.uri);
540
+ });
523
541
  WebPlayer.DEFAULT_PLAY_ORDER = ["webrtc", "hls"];
524
542
  WebPlayer.DEFAULT_PLAY_TYPE = ["mp4", "webm"];
525
543
  WebPlayer.HLS_EXTENSION = "m3u8";
@@ -537,15 +555,19 @@ class WebPlayer {
537
555
  // Initialize default values
538
556
  this.setDefaults();
539
557
 
558
+
540
559
  // Check if the first argument is a config object or a Window object
541
560
  if (!this.isWindow(configOrWindow)) {
542
561
  // New config object mode
543
562
  Logger_1.info("config object mode");
563
+ console.log("config object mode");
564
+
544
565
  Object.assign(this, configOrWindow);
545
566
  this.window = window;
546
567
  } else {
547
568
  // Backward compatibility mode
548
569
  Logger_1.info("getting from url mode");
570
+ console.log("getting from url mode");
549
571
  this.window = configOrWindow;
550
572
 
551
573
  // Use getUrlParameter for backward compatibility
@@ -722,12 +744,12 @@ class WebPlayer {
722
744
  }
723
745
  loadWebRTCComponents() {
724
746
  if (this.playOrder.includes("webrtc")) {
725
- return import('./videojs-webrtc-plugin-7e293bd2.js').then(css => {
747
+ return import('./videojs-webrtc-plugin-5fadffd3.js').then(css => {
726
748
  Logger_1.info("videojs-webrtc-plugin.css is loaded");
727
749
  var styleElement = this.dom.createElement('style');
728
750
  styleElement.textContent = css.default.toString(); // Assuming css module exports a string
729
751
  this.dom.head.appendChild(styleElement);
730
- return import('./videojs-webrtc-plugin.es-df625b38.js').then(videojsWebrtcPluginLocal => {
752
+ return import('./videojs-webrtc-plugin.es-f339fb8c.js').then(videojsWebrtcPluginLocal => {
731
753
  Logger_1.info("videojs-webrtc-plugin is loaded");
732
754
  });
733
755
  });
@@ -748,12 +770,12 @@ class WebPlayer {
748
770
  styleElement.textContent = css.default.toString(); // Assuming css module exports a string
749
771
  this.dom.head.appendChild(styleElement);
750
772
  }).then(() => {
751
- return import('./video.es-be70c095.js');
773
+ return import('./video.es-0951ae41.js').then(function (n) { return n.a; });
752
774
  }).then(videojs => {
753
775
  window.videojs = videojs.default;
754
776
  this.videojsLoaded = true;
755
777
  }).then(() => {
756
- return import('./plugin-50e1316e.js');
778
+ return import('./plugin-06260ef3.js');
757
779
  }).then(() => {
758
780
  return this.loadWebRTCComponents();
759
781
  });
@@ -819,10 +841,9 @@ class WebPlayer {
819
841
  }, 2000);
820
842
  } else if (infos["info"] == "streaming_started") {
821
843
  Logger_1.info("Requested stream has started");
822
- this.playIfExists(this.currentPlayType, this.activeStreamId);
844
+ this.playIfExists(this.currentPlayType, infos["obj"].streamId);
823
845
  }
824
846
  }
825
-
826
847
  /**
827
848
  * Play the stream via videojs
828
849
  * @param {*} streamUrl
@@ -859,6 +880,9 @@ class WebPlayer {
859
880
  }
860
881
 
861
882
  //same videojs is being use for hls, vod and webrtc streams
883
+ var videoPlayererer = this.dom.getElementById(this.videoPlayerId);
884
+ console.log("videoPlayererer", videoPlayererer);
885
+
862
886
  this.videojsPlayer = videojs(this.videoPlayerId, {
863
887
  poster: "previews/" + preview + ".png",
864
888
  liveui: extension == "m3u8" ? true : false,
@@ -890,7 +914,14 @@ class WebPlayer {
890
914
  && errors["message"]["information"] == "stream_not_exist_or_not_streaming") {
891
915
  // server puts the this client to the waiting list automatically and it will notify with
892
916
  //streaming_started event
893
- Logger_1.info("Stream does not exists or not started yet. Waiting for the stream to start. It will be notified with streaming_started event by the server");
917
+
918
+ //check if backup stream id is set
919
+ if (this.backupStreamId != null) {
920
+ this.tryNextTech();
921
+ } else {
922
+ //if backup stream id is not set, let the server notify
923
+ Logger_1.info("Stream " + errors["message"]["streamId"] + " does not exists or not started yet. Waiting for the stream to start. It will be notified with streaming_started event by the server");
924
+ }
894
925
  } else if (errors["error"] == "no_stream_exist" || errors["error"] == "WebSocketNotConnected" || errors["error"] == "not_initialized_yet" || errors["error"] == "data_store_not_available" || errors["error"] == "highResourceUsage" || errors["error"] == "unauthorized_access" || errors["error"] == "user_blocked") {
895
926
  //handle high resource usage and not authroized errors && websocket disconnected
896
927
  //Even if webrtc adaptor has auto reconnect scenario, we dispose the videojs immediately in tryNextTech
@@ -918,23 +949,12 @@ class WebPlayer {
918
949
 
919
950
  //hls specific calls
920
951
  if (extension == "m3u8") {
921
- videojs.Vhs.xhr.onRequest = options => {
922
- var queryParams = [];
923
- if (!options.uri.includes("subscriberId") && this.subscriberId != null) {
924
- queryParams.push("subscriberId=".concat(this.subscriberId));
925
- }
926
- if (!options.uri.includes("subscriberCode") && this.subscriberCode != null) {
927
- queryParams.push("subscriberCode=".concat(this.subscriberCode));
928
- }
929
- if (!options.uri.includes("token") && this.token != null) {
930
- queryParams.push("token=".concat(this.token));
931
- }
932
- if (queryParams.length > 0) {
933
- var queryString = queryParams.join("&");
934
- options.uri += options.uri.includes("?") ? "&".concat(queryString) : "?".concat(queryString);
935
- }
936
- Logger_1.debug("hls request: " + options.uri);
937
- };
952
+ this.videojsPlayer.on('xhr-hooks-ready', () => {
953
+ this.videojsPlayer.ready(() => {
954
+ // tech is ready after ready event
955
+ this.videojsPlayer.tech().vhs.xhr.onRequest(this.insertSecurityParameters);
956
+ });
957
+ });
938
958
  this.videojsPlayer.ready(() => {
939
959
  // If it's already added to player, no need to add again
940
960
  if (typeof this.videojsPlayer.qualitySelectorHls === "function") {
@@ -1370,6 +1390,8 @@ class WebPlayer {
1370
1390
  _this.destroyDashPlayer();
1371
1391
  _this.setPlayerVisible(false);
1372
1392
  _this.containerElement.innerHTML = _this.videoHTMLContent;
1393
+ console.log("videoHTMLContent:", _this.videoHTMLContent);
1394
+ console.log("containerElement:", _this.containerElement);
1373
1395
  Logger_1.warn("Try to play the stream " + streamIdToPlay + " with " + _this.currentPlayType);
1374
1396
  switch (_this.currentPlayType) {
1375
1397
  case "hls":
@@ -1445,13 +1467,17 @@ class WebPlayer {
1445
1467
  getSecurityQueryParams() {
1446
1468
  var queryString = "";
1447
1469
  if (this.token != null) {
1448
- queryString += "&token=" + this.token;
1470
+ queryString += "token=" + this.token + "&";
1449
1471
  }
1450
1472
  if (this.subscriberId != null) {
1451
- queryString += "&subscriberId=" + this.subscriberId;
1473
+ queryString += "subscriberId=" + this.subscriberId + "&";
1452
1474
  }
1453
1475
  if (this.subscriberCode != null) {
1454
- queryString += "&subscriberCode=" + this.subscriberCode;
1476
+ queryString += "subscriberCode=" + this.subscriberCode + "&";
1477
+ }
1478
+ //remove the last character if it's "&"
1479
+ if (queryString.endsWith("&")) {
1480
+ queryString = queryString.substring(0, queryString.length - 1);
1455
1481
  }
1456
1482
  return queryString;
1457
1483
  }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ var videojsWebrtcPlugin = "/*! @name @antmedia/videojs-webrtc-plugin @version 1.3.3 @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}";
4
+
5
+ exports.default = videojsWebrtcPlugin;