@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.
@@ -232,6 +232,24 @@
232
232
  * It can be streamID or backupStreamId
233
233
  */
234
234
  _defineProperty(this, "activeStreamId", void 0);
235
+ // we define insertSecurityParameters in this way because we want to get the this context such as this.subscriberId
236
+ _defineProperty(this, "insertSecurityParameters", options => {
237
+ var queryParams = [];
238
+ if (!options.uri.includes("subscriberId") && this.subscriberId != null) {
239
+ queryParams.push("subscriberId=".concat(this.subscriberId));
240
+ }
241
+ if (!options.uri.includes("subscriberCode") && this.subscriberCode != null) {
242
+ queryParams.push("subscriberCode=".concat(this.subscriberCode));
243
+ }
244
+ if (!options.uri.includes("token") && this.token != null) {
245
+ queryParams.push("token=".concat(this.token));
246
+ }
247
+ if (queryParams.length > 0) {
248
+ var queryString = queryParams.join("&");
249
+ options.uri += options.uri.includes("?") ? "&".concat(queryString) : "?".concat(queryString);
250
+ }
251
+ loglevel_min.Logger.debug("hls request: " + options.uri);
252
+ });
235
253
  WebPlayer.DEFAULT_PLAY_ORDER = ["webrtc", "hls"];
236
254
  WebPlayer.DEFAULT_PLAY_TYPE = ["mp4", "webm"];
237
255
  WebPlayer.HLS_EXTENSION = "m3u8";
@@ -531,10 +549,9 @@
531
549
  }, 2000);
532
550
  } else if (infos["info"] == "streaming_started") {
533
551
  loglevel_min.Logger.info("Requested stream has started");
534
- this.playIfExists(this.currentPlayType, this.activeStreamId);
552
+ this.playIfExists(this.currentPlayType, infos["obj"].streamId);
535
553
  }
536
554
  }
537
-
538
555
  /**
539
556
  * Play the stream via videojs
540
557
  * @param {*} streamUrl
@@ -602,7 +619,14 @@
602
619
  && errors["message"]["information"] == "stream_not_exist_or_not_streaming") {
603
620
  // server puts the this client to the waiting list automatically and it will notify with
604
621
  //streaming_started event
605
- loglevel_min.Logger.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");
622
+
623
+ //check if backup stream id is set
624
+ if (this.backupStreamId != null) {
625
+ this.tryNextTech();
626
+ } else {
627
+ //if backup stream id is not set, let the server notify
628
+ loglevel_min.Logger.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");
629
+ }
606
630
  } 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") {
607
631
  //handle high resource usage and not authroized errors && websocket disconnected
608
632
  //Even if webrtc adaptor has auto reconnect scenario, we dispose the videojs immediately in tryNextTech
@@ -630,23 +654,12 @@
630
654
 
631
655
  //hls specific calls
632
656
  if (extension == "m3u8") {
633
- videojs.Vhs.xhr.onRequest = options => {
634
- var queryParams = [];
635
- if (!options.uri.includes("subscriberId") && this.subscriberId != null) {
636
- queryParams.push("subscriberId=".concat(this.subscriberId));
637
- }
638
- if (!options.uri.includes("subscriberCode") && this.subscriberCode != null) {
639
- queryParams.push("subscriberCode=".concat(this.subscriberCode));
640
- }
641
- if (!options.uri.includes("token") && this.token != null) {
642
- queryParams.push("token=".concat(this.token));
643
- }
644
- if (queryParams.length > 0) {
645
- var queryString = queryParams.join("&");
646
- options.uri += options.uri.includes("?") ? "&".concat(queryString) : "?".concat(queryString);
647
- }
648
- loglevel_min.Logger.debug("hls request: " + options.uri);
649
- };
657
+ this.videojsPlayer.on('xhr-hooks-ready', () => {
658
+ this.videojsPlayer.ready(() => {
659
+ // tech is ready after ready event
660
+ this.videojsPlayer.tech().vhs.xhr.onRequest(this.insertSecurityParameters);
661
+ });
662
+ });
650
663
  this.videojsPlayer.ready(() => {
651
664
  // If it's already added to player, no need to add again
652
665
  if (typeof this.videojsPlayer.qualitySelectorHls === "function") {
@@ -1157,13 +1170,17 @@
1157
1170
  getSecurityQueryParams() {
1158
1171
  var queryString = "";
1159
1172
  if (this.token != null) {
1160
- queryString += "&token=" + this.token;
1173
+ queryString += "token=" + this.token + "&";
1161
1174
  }
1162
1175
  if (this.subscriberId != null) {
1163
- queryString += "&subscriberId=" + this.subscriberId;
1176
+ queryString += "subscriberId=" + this.subscriberId + "&";
1164
1177
  }
1165
1178
  if (this.subscriberCode != null) {
1166
- queryString += "&subscriberCode=" + this.subscriberCode;
1179
+ queryString += "subscriberCode=" + this.subscriberCode + "&";
1180
+ }
1181
+ //remove the last character if it's "&"
1182
+ if (queryString.endsWith("&")) {
1183
+ queryString = queryString.substring(0, queryString.length - 1);
1167
1184
  }
1168
1185
  return queryString;
1169
1186
  }
@@ -199,6 +199,7 @@ export declare class WebPlayer {
199
199
  */
200
200
  setPlayerVisible(visible: boolean): void;
201
201
  handleWebRTCInfoMessages(infos: any): void;
202
+ insertSecurityParameters: (options: any) => void;
202
203
  /**
203
204
  * Play the stream via videojs
204
205
  * @param {*} streamUrl
@@ -0,0 +1,3 @@
1
+ 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}";
2
+
3
+ export { videojsWebrtcPlugin as default };