@flashphoner/websdk 2.0.235 → 2.0.237

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.
Files changed (29) hide show
  1. package/docTemplate/README.md +1 -1
  2. package/examples/demo/dependencies/js/utils.js +78 -19
  3. package/examples/demo/streaming/hls-player/hls-player.html +17 -4
  4. package/examples/demo/streaming/hls-player/hls-player.js +177 -54
  5. package/examples/demo/streaming/hls-player/player-page.html +6 -4
  6. package/examples/demo/streaming/hls-player/{video.js → videojs7/video.js} +16 -6
  7. package/examples/demo/streaming/hls-player/{video.min.js → videojs7/video.min.js} +3 -3
  8. package/examples/demo/streaming/hls-player/videojs8/video-js.css +1946 -0
  9. package/examples/demo/streaming/hls-player/videojs8/video.js +64556 -0
  10. package/examples/demo/streaming/hls-player/videojs8/video.min.js +46 -0
  11. package/flashphoner-no-flash.js +48 -23
  12. package/flashphoner-no-flash.min.js +2 -2
  13. package/flashphoner-no-webrtc.js +3 -10
  14. package/flashphoner-no-webrtc.min.js +2 -2
  15. package/flashphoner-no-wsplayer.js +48 -23
  16. package/flashphoner-no-wsplayer.min.js +2 -2
  17. package/flashphoner-room-api.js +60 -19
  18. package/flashphoner-room-api.min.js +3 -3
  19. package/flashphoner-temasys-flash-websocket-without-adapterjs.js +3 -10
  20. package/flashphoner-temasys-flash-websocket.js +3 -10
  21. package/flashphoner-temasys-flash-websocket.min.js +1 -1
  22. package/flashphoner-webrtc-only.js +46 -21
  23. package/flashphoner-webrtc-only.min.js +1 -1
  24. package/flashphoner.js +48 -23
  25. package/flashphoner.min.js +2 -2
  26. package/package.json +1 -1
  27. package/src/media-source-media-provider.js +2 -2
  28. package/src/webrtc-media-provider.js +58 -17
  29. /package/examples/demo/streaming/hls-player/{video-js.css → videojs7/video-js.css} +0 -0
@@ -1,4 +1,4 @@
1
- Web SDK - 2.0.235
1
+ Web SDK - 2.0.237
2
2
 
3
3
  [Download builds](https://docs.flashphoner.com/display/WEBSDK2EN/Web+SDK+release+notes)
4
4
 
@@ -317,25 +317,6 @@ function detectFlash() {
317
317
  }
318
318
  }
319
319
 
320
- $(function () {
321
- function reposition() {
322
- var modal = $(this),
323
- dialog = modal.find('.modal-dialog');
324
- modal.css('display', 'block');
325
-
326
- // Dividing by two centers the modal exactly, but dividing by three
327
- // or four works better for larger screens.
328
- dialog.css("margin-top", Math.max(0, ($(window).height() - dialog.height()) / 2));
329
- }
330
-
331
- // Reposition when a modal is shown
332
- $('.modal').on('show.bs.modal', reposition);
333
- // Reposition when the window is resized
334
- $(window).on('resize', function () {
335
- $('.modal:visible').each(reposition);
336
- });
337
- });
338
-
339
320
  /**
340
321
  * Generate simple uuid
341
322
  *
@@ -473,3 +454,81 @@ function canWebkitFullScreen(video) {
473
454
  }
474
455
  return canFullscreen;
475
456
  }
457
+
458
+ // Helper function to set item text
459
+ const setText = function (id, text) {
460
+ let item = document.getElementById(id);
461
+ if (item) {
462
+ item.innerHTML = text;
463
+ }
464
+ }
465
+
466
+ // Helper functions to set/get an item value
467
+ const setValue = function (id, value) {
468
+ let item = document.getElementById(id);
469
+ if (item) {
470
+ item.value = value;
471
+ }
472
+ }
473
+
474
+ const getValue = function (id) {
475
+ let item = document.getElementById(id);
476
+ if (item) {
477
+ return item.value;
478
+ }
479
+ return null;
480
+ }
481
+
482
+ // Helper functions to display/hide an item
483
+ const showItem = function(id) {
484
+ let item = document.getElementById(id);
485
+ if (item) {
486
+ item.style.display = "block";
487
+ }
488
+ }
489
+
490
+ const hideItem = function(id) {
491
+ let item = document.getElementById(id);
492
+ if (item) {
493
+ item.style.display = "none";
494
+ }
495
+ }
496
+
497
+ // Helper functions to disable/enable an item
498
+ const disableItem = function(id) {
499
+ let item = document.getElementById(id);
500
+ if (item) {
501
+ item.disabled = true;
502
+ }
503
+ }
504
+
505
+ const enableItem = function(id) {
506
+ let item = document.getElementById(id);
507
+ if (item) {
508
+ item.disabled = false;
509
+ }
510
+ }
511
+
512
+ // Set an event handler
513
+ const setHandler = function (id, event, handler, previous = null) {
514
+ let item = document.getElementById(id);
515
+ if (item) {
516
+ if (previous) {
517
+ item.removeEventListener(event, previous)
518
+ }
519
+ item.addEventListener(event, handler);
520
+ }
521
+ }
522
+
523
+ // Find a closest item
524
+ const closest = function (id, selector) {
525
+ let currentElement = document.getElementById(id);
526
+ let returnElement = null;
527
+
528
+ while (currentElement && currentElement.parentNode && !returnElement) {
529
+ currentElement = currentElement.parentNode;
530
+ returnElement = currentElement.querySelector(selector);
531
+ }
532
+
533
+ return returnElement;
534
+ }
@@ -5,16 +5,29 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <link rel="stylesheet" href="../../dependencies/bootstrap/css/bootstrap.css">
7
7
  <link rel="stylesheet" href="hls-player.css">
8
- <link rel="stylesheet" href="video-js.css">
8
+ <!-- <link rel="stylesheet" href="video-js.css"> -->
9
9
  <title>HLS VideoJS Player Minimal</title>
10
10
  <script type="text/javascript" src="../../../../flashphoner.js"></script>
11
- <script type="text/javascript" src="../../dependencies/jquery/jquery-1.12.0.js"></script>
12
- <script type="text/javascript" src="../../dependencies/jquery/jquery-ui.js"></script>
11
+ <!-- <script type="text/javascript" src="../../dependencies/jquery/jquery-1.12.0.js"></script>
12
+ <script type="text/javascript" src="../../dependencies/jquery/jquery-ui.js"></script> -->
13
13
  <script type="text/javascript" src="../../dependencies/js/utils.js"></script>
14
14
  <script type="text/javascript" src="hls-player.js"></script>
15
- <script type="text/javascript" src="video.js"></script>
15
+ <!-- <script type="text/javascript" src="video.js"></script> -->
16
16
  </head>
17
17
  <body onload="loadPlayerPage()">
18
+ <div class="row form-group" id="videojsInputForm">
19
+ <label style="text-align: right" class="col-sm-4 control-label">VideoJS version</label>
20
+ <div class="col-sm-4">
21
+ <select class="form-control" id="videojsInput">
22
+ </select>
23
+ </div>
24
+ <div class="col-sm-10 text-center" style="margin-top: 20px">
25
+ <button id="videojsBtn" type="button" class="btn btn-default">Run</button>
26
+ </div>
27
+ <div class="col-sm-10 text-center" style="margin-top: 20px">
28
+ <div id="videojsError" class="text-danger"></div>
29
+ </div>
30
+ </div>
18
31
  <div id="playerPage" class="container">
19
32
  </div>
20
33
  </body>
@@ -1,26 +1,133 @@
1
- var Browser = Flashphoner.Browser;
2
- var player = null;
1
+ const Browser = Flashphoner.Browser;
2
+ const VIDEOJS_VERSION_TYPE = {
3
+ VIDEOJS7: "videojs7",
4
+ VIDEOJS8: "videojs8"
5
+ };
6
+ let player = null;
7
+ let videojsVersion = getUrlParam("version");
3
8
 
4
- function loadPlayerPage() {
5
- $("#playerPage").load("player-page.html", initPage );
9
+ const loadPlayerPage = function() {
10
+ if (videojsVersion) {
11
+ hideItem("videojsInputForm");
12
+ loadVideoJS("videojs" + videojsVersion);
13
+ } else {
14
+ let videojsInput = document.getElementById("videojsInput");
15
+ for (videojsType in VIDEOJS_VERSION_TYPE) {
16
+ let option = document.createElement("option");
17
+ let videojsFolder = "";
18
+ switch (videojsType) {
19
+ case 'VIDEOJS7':
20
+ videojsFolder = VIDEOJS_VERSION_TYPE.VIDEOJS7;
21
+ break;
22
+ case 'VIDEOJS8':
23
+ videojsFolder = VIDEOJS_VERSION_TYPE.VIDEOJS8;
24
+ break;
25
+ }
26
+ option.text = videojsFolder;
27
+ option.value = videojsFolder;
28
+ videojsInput.appendChild(option);
29
+ }
30
+
31
+ setHandler("videojsBtn", "click", onVideojsBtnClick);
32
+ }
33
+ }
34
+
35
+ const onVideojsBtnClick = function () {
36
+ loadVideoJS(getValue("videojsInput"));
37
+ }
38
+
39
+ const loadVideoJS = function (version) {
40
+ if (version) {
41
+ let playerPage = document.getElementById("playerPage");
42
+ loadFile(version + "/video.js", "text/javascript").then( data => {
43
+ console.log("HLS library loaded successfully", data);
44
+ loadFile(version + "/video-js.css", "stylesheet").then ( data => {
45
+ console.log("HLS library stylesheet loaded successfully", data);
46
+ hideItem("videojsInputForm");
47
+ loadPage("player-page.html", "playerPage", initPage );
48
+ }).catch( err => {
49
+ playerPage.innerHTML = "Can't load VideoJS library stylesheet";
50
+ playerPage.setAttribute("class", "text-danger");
51
+ console.error(err);
52
+ })
53
+ }).catch( err => {
54
+ setText("videojsError", "Can't load VideoJS library");
55
+ console.error(err);
56
+ });
57
+ }
58
+ }
59
+
60
+ const loadFile = function(url, type) {
61
+ return new Promise((resolve, reject) => {
62
+ try {
63
+ let tag = null;
64
+ if (type === "text/javascript") {
65
+ tag = document.createElement("script");
66
+ tag.type = type;
67
+ tag.async = true;
68
+ tag.src = url;
69
+ } else if (type === "stylesheet") {
70
+ tag = document.createElement("link");
71
+ tag.rel = type;
72
+ tag.href = url;
73
+ }
74
+
75
+ if (tag) {
76
+ tag.addEventListener("load", (ev) => {
77
+ resolve({status: true});
78
+ });
79
+
80
+ tag.addEventListener("error", (ev) => {
81
+ reject({
82
+ status: false,
83
+ message: `Failed to load the file ${url}`
84
+ });
85
+ });
86
+
87
+ document.head.appendChild(tag);
88
+ } else {
89
+ reject({
90
+ status: false,
91
+ message: `Undefined file type ${type}`
92
+ });
93
+ }
94
+ } catch (error) {
95
+ reject(error);
96
+ }
97
+ });
98
+ }
99
+
100
+ const loadPage = function(page, containerId, onLoad) {
101
+ fetch(page).then(function (response) {
102
+ if (response.ok) {
103
+ return response.text();
104
+ }
105
+ throw response;
106
+ }).then(function (text) {
107
+ let container = document.getElementById(containerId);
108
+ container.innerHTML = text;
109
+ onLoad();
110
+ });
6
111
  }
7
112
 
8
- function initPage() {
9
- $("#header").text("HLS VideoJS Player Minimal");
10
- $("#urlServer").val(getHLSUrl());
11
- $("#applyBtn").prop('disabled', false).text("Play").off('click').click(playBtnClick);
12
- var remoteVideo = document.getElementById('remoteVideo');
113
+ const initPage = function() {
114
+ setText("header", "HLS VideoJS Player Minimal");
115
+ setValue("urlServer", getHLSUrl());
116
+ enableItem("applyBtn");
117
+ setText("applyBtn", "Play");
118
+ setHandler("applyBtn", "click", playBtnClick);
119
+ let remoteVideo = document.getElementById('remoteVideo');
13
120
  remoteVideo.className = "video-js vjs-default-skin";
14
121
  player = initVideoJsPlayer(remoteVideo);
15
122
  }
16
123
 
17
- function playBtnClick() {
124
+ const playBtnClick = function() {
18
125
  if (validateForm()) {
19
- var streamName = $('#playStream').val();
126
+ let streamName = getValue('playStream');
20
127
  streamName = encodeURIComponent(streamName);
21
- var videoSrc = $("#urlServer").val() + '/' + streamName + '/' + streamName + '.m3u8';
22
- var key = $('#key').val();
23
- var token = $("#token").val();
128
+ let videoSrc = getValue("urlServer") + '/' + streamName + '/' + streamName + '.m3u8';
129
+ let key = getValue('key');
130
+ let token = getValue("token");
24
131
  if (key.length > 0 && token.length > 0) {
25
132
  videoSrc += "?" + key + "=" + token;
26
133
  }
@@ -29,7 +136,7 @@ function playBtnClick() {
29
136
  player.play();
30
137
  });
31
138
  player.on('error', function() {
32
- var error = player.error();
139
+ let error = player.error();
33
140
  // Stop on error
34
141
  stopBtnClick();
35
142
  if (error && error.code == error.MEDIA_ERR_DECODE) {
@@ -46,7 +153,7 @@ function playBtnClick() {
46
153
  }
47
154
 
48
155
 
49
- function stopBtnClick() {
156
+ const stopBtnClick = function() {
50
157
  if (player != null) {
51
158
  console.log("Stop VideoJS player");
52
159
  //player.pause();
@@ -56,30 +163,34 @@ function stopBtnClick() {
56
163
  }
57
164
 
58
165
 
59
- function onStarted() {
60
- $("#urlServer").prop('disabled', true);
61
- $("#playStream").prop('disabled', true);
62
- $("#key").prop('disabled', true);
63
- $("#token").prop('disabled', true);
64
- $("#player").prop('disabled', true);
65
- $("#applyBtn").prop('disabled', false).text("Stop").off('click').click(stopBtnClick);
166
+ const onStarted = function() {
167
+ disableItem("urlServer");
168
+ disableItem("playStream");
169
+ disableItem("key");
170
+ disableItem("token");
171
+ disableItem("player");
172
+ enableItem("applyBtn");
173
+ setText("applyBtn", "Stop");
174
+ setHandler("applyBtn", "click", stopBtnClick, playBtnClick);
66
175
  }
67
176
 
68
177
 
69
- function onStopped() {
70
- $("#urlServer").prop('disabled', false);
71
- $("#playStream").prop('disabled', false);
72
- $("#key").prop('disabled', false);
73
- $("#token").prop('disabled', false);
74
- $("#player").prop('disabled', false);
75
- $("#applyBtn").prop('disabled', false).text("Play").off('click').click(playBtnClick);
178
+ const onStopped = function() {
179
+ enableItem("urlServer");
180
+ enableItem("playStream");
181
+ enableItem("key");
182
+ enableItem("token");
183
+ enableItem("player");
184
+ enableItem("applyBtn");
185
+ setText("applyBtn", "Play");
186
+ setHandler("applyBtn", "click", playBtnClick, stopBtnClick);
76
187
  if(!document.getElementById('remoteVideo')) {
77
188
  createRemoteVideo(document.getElementById('videoContainer'));
78
189
  }
79
190
  }
80
191
 
81
192
 
82
- function createRemoteVideo(parent) {
193
+ const createRemoteVideo = function(parent) {
83
194
  remoteVideo = document.createElement("video");
84
195
  remoteVideo.id = "remoteVideo";
85
196
  remoteVideo.width=852;
@@ -95,41 +206,53 @@ function createRemoteVideo(parent) {
95
206
  }
96
207
 
97
208
 
98
- function validateForm() {
99
- var valid = true;
100
- if (!$("#urlServer").val().length) {
101
- highlightInput($("#urlServer"));
102
- valid = false;
103
- } else {
104
- removeHighlight($("#urlServer"));
209
+ const validateForm = function() {
210
+ let valid = validateInput("urlServer");
211
+ if (valid) {
212
+ valid = validateInput("playStream");
105
213
  }
106
- if (!$("#playStream").val().length) {
107
- highlightInput($("#playStream"));
214
+ return valid;
215
+ }
216
+
217
+ const validateInput = function(id) {
218
+ let value = getValue(id);
219
+ let valid = true;
220
+ if (!value || !value.length) {
221
+ highlightInput(id);
108
222
  valid = false;
109
223
  } else {
110
- removeHighlight($("#playStream"));
224
+ removeHighlight(id);
111
225
  }
112
-
113
226
  return valid;
114
-
115
227
  }
116
228
 
117
-
118
- function highlightInput(input) {
119
- input.closest('.form-group').addClass("has-error");
229
+ const highlightInput = function(input) {
230
+ let item = document.getElementById(input);
231
+ if (item) {
232
+ let parent = closest(input,'.form-group');
233
+ if (parent) {
234
+ parent.classList.add("has-error");
235
+ }
236
+ }
120
237
  }
121
238
 
122
239
 
123
- function removeHighlight(input) {
124
- input.closest('.form-group').removeClass("has-error");
240
+ const removeHighlight = function(input) {
241
+ let item = document.getElementById(input);
242
+ if (item) {
243
+ let parent = closest(input,'.form-group');
244
+ if (parent) {
245
+ parent.classList.remove("has-error");
246
+ }
247
+ }
125
248
  }
126
249
 
127
- function initVideoJsPlayer(video) {
128
- var videoJsPlayer = videojs(video);
250
+ const initVideoJsPlayer = function(video) {
251
+ let videoJsPlayer = videojs(video);
129
252
  console.log("Using VideoJs " + videojs.VERSION);
130
253
  if (Browser.isSafariWebRTC() && Browser.isiOS()) {
131
254
  // iOS hack when using standard controls to leave fullscreen mode
132
- var videoTag = getActualVideoTag();
255
+ let videoTag = getActualVideoTag();
133
256
  if(videoTag) {
134
257
  setWebkitFullscreenHandlers(videoTag);
135
258
  }
@@ -137,10 +260,10 @@ function initVideoJsPlayer(video) {
137
260
  return videoJsPlayer;
138
261
  }
139
262
 
140
- function getActualVideoTag() {
141
- var videos = document.querySelectorAll("video");
263
+ const getActualVideoTag = function() {
264
+ let videos = document.querySelectorAll("video");
142
265
  if (videos && videos.length > 0) {
143
266
  return videos[0];
144
267
  }
145
268
  return null;
146
- }
269
+ }
@@ -6,11 +6,13 @@
6
6
  <h2 id="notifyFlash" class="text-danger"></h2>
7
7
  <fieldset id="fieldset" class="scheduler-border fp-streamingControls">
8
8
  <div class="row" style="margin-top: 20px">
9
- <label class="control-label col-sm-1 fp-buttonVerticalAlign text-right" for="urlServer">WCS
10
- URL</label>
9
+ <div id="urlForm" class="form-group">
10
+ <label class="control-label col-sm-1 fp-buttonVerticalAlign text-right" for="urlServer">WCS
11
+ URL</label>
11
12
 
12
- <div class="col-sm-12">
13
- <input type="text" class="form-control" id="urlServer" placeholder="WCS Server URL"/>
13
+ <div class="col-sm-12">
14
+ <input type="text" class="form-control" id="urlServer" placeholder="WCS Server URL"/>
15
+ </div>
14
16
  </div>
15
17
  </div>
16
18
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Video.js 7.21.3 <http://videojs.com/>
3
+ * Video.js 7.21.5 <http://videojs.com/>
4
4
  * Copyright Brightcove, Inc. <https://www.brightcove.com/>
5
5
  * Available under Apache License Version 2.0
6
6
  * <https://github.com/videojs/video.js/blob/main/LICENSE>
@@ -16,7 +16,7 @@
16
16
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.videojs = factory());
17
17
  }(this, (function () { 'use strict';
18
18
 
19
- var version$5 = "7.21.3";
19
+ var version$5 = "7.21.5";
20
20
 
21
21
  /**
22
22
  * An Object that contains lifecycle hooks as keys which point to an array
@@ -8632,7 +8632,7 @@
8632
8632
  _proto.addCue = function addCue(originalCue) {
8633
8633
  var cue = originalCue;
8634
8634
 
8635
- if (window.vttjs && !(originalCue instanceof window.vttjs.VTTCue)) {
8635
+ if (cue.constructor && cue.constructor.name !== 'VTTCue') {
8636
8636
  cue = new window.vttjs.VTTCue(originalCue.startTime, originalCue.endTime, originalCue.text);
8637
8637
 
8638
8638
  for (var prop in originalCue) {
@@ -9683,6 +9683,7 @@
9683
9683
 
9684
9684
  switch (cue.positionAlign) {
9685
9685
  case "start":
9686
+ case "line-left":
9686
9687
  textPos = cue.position;
9687
9688
  break;
9688
9689
 
@@ -9691,6 +9692,7 @@
9691
9692
  break;
9692
9693
 
9693
9694
  case "end":
9695
+ case "line-right":
9694
9696
  textPos = cue.position - cue.size;
9695
9697
  break;
9696
9698
  } // Horizontal box orientation; textPos is the distance from the left edge of the
@@ -26968,7 +26970,8 @@
26968
26970
  }
26969
26971
 
26970
26972
  this.playCallbacks_.push(callback);
26971
- var isSrcReady = Boolean(!this.changingSrc_ && (this.src() || this.currentSrc())); // treat calls to play_ somewhat like the `one` event function
26973
+ var isSrcReady = Boolean(!this.changingSrc_ && (this.src() || this.currentSrc()));
26974
+ var isSafariOrIOS = Boolean(IS_ANY_SAFARI || IS_IOS); // treat calls to play_ somewhat like the `one` event function
26972
26975
 
26973
26976
  if (this.waitToPlay_) {
26974
26977
  this.off(['ready', 'loadstart'], this.waitToPlay_);
@@ -26985,7 +26988,7 @@
26985
26988
  this.one(['ready', 'loadstart'], this.waitToPlay_); // if we are in Safari, there is a high chance that loadstart will trigger after the gesture timeperiod
26986
26989
  // in that case, we need to prime the video element by calling load so it'll be ready in time
26987
26990
 
26988
- if (!isSrcReady && (IS_ANY_SAFARI || IS_IOS)) {
26991
+ if (!isSrcReady && isSafariOrIOS) {
26989
26992
  this.load();
26990
26993
  }
26991
26994
 
@@ -26993,7 +26996,14 @@
26993
26996
  } // If the player/tech is ready and we have a source, we can attempt playback.
26994
26997
 
26995
26998
 
26996
- var val = this.techGet_('play'); // play was terminated if the returned value is null
26999
+ var val = this.techGet_('play'); // For native playback, reset the progress bar if we get a play call from a replay.
27000
+
27001
+ var isNativeReplay = isSafariOrIOS && this.hasClass('vjs-ended');
27002
+
27003
+ if (isNativeReplay) {
27004
+ this.resetProgressBar_();
27005
+ } // play was terminated if the returned value is null
27006
+
26997
27007
 
26998
27008
  if (val === null) {
26999
27009
  this.runPlayTerminatedQueue_();