@flashphoner/websdk 2.0.225 → 2.0.227

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.
@@ -1,4 +1,4 @@
1
- Web SDK - 2.0.225
1
+ Web SDK - 2.0.227
2
2
 
3
3
  [Download builds](https://docs.flashphoner.com/display/WEBSDK2EN/Web+SDK+release+notes)
4
4
 
@@ -27,8 +27,8 @@ function init_page() {
27
27
  $("#testBtn").click(function () {
28
28
  $("#fp_embed_player").attr('src', "player.html?" +
29
29
  "urlServer=" + $("#url").val() + "&" +
30
- "streamName=" + $("#streamName").val().replace(/&/g,encodeURIComponent("&")) + "&" +
31
- "mediaProviders=" + getMediaProviders() + "&" +
30
+ "streamName=" + encodeURIComponent($("#streamName").val()) + "&" +
31
+ "mediaProviders=" + getMediaProviders() + "&" +
32
32
  "autoplay=false");
33
33
  });
34
34
  $("#clipboardBtn").click(function () {
@@ -38,7 +38,7 @@ function init_page() {
38
38
  var constructCode = function () {
39
39
  var url = getAdminUrl() + "/embed_player?" +
40
40
  "urlServer=" + $("#url").val() + "&" +
41
- "streamName=" + $("#streamName").val().replace(/&/g,encodeURIComponent("&")) + "&" +
41
+ "streamName=" + encodeURIComponent($("#streamName").val()) + "&" +
42
42
  "mediaProviders=" + getMediaProviders();
43
43
  $("#codeTextArea").text("<iframe id='fp_embed_player' src='" + url + "' " +
44
44
  "marginwidth='0' marginheight='0' frameborder='0' width='100%' height='100%' scrolling='no' allowfullscreen='allowfullscreen'></iframe>")
@@ -51,7 +51,7 @@ function init_page() {
51
51
  });
52
52
  constructCode();
53
53
 
54
- // Подгружаем dark.css по умолчанию
54
+ // Add dark style to player frame
55
55
  $('#fp_embed_player').contents().find('html').addClass('dark-style');
56
56
  $('.fp-remoteVideo').addClass('dark-style-bg');
57
57
 
@@ -1,4 +1,7 @@
1
- //Set WCS URL
1
+ /**
2
+ * Set WCS URL
3
+ * @return WCS URL to connect
4
+ */
2
5
  function setURL() {
3
6
  let proto;
4
7
  let url;
@@ -15,20 +18,55 @@ function setURL() {
15
18
  return url;
16
19
  }
17
20
 
21
+
22
+ /**
23
+ * Check if value is URI encoded
24
+ * @param value a string to check for encoding
25
+ * @return true if value is encoded
26
+ */
27
+ function isEncoded(value) {
28
+ value = value || '';
29
+ let result;
30
+
31
+ try {
32
+ result = (value !== decodeURIComponent(value));
33
+ } catch (e) {
34
+ result = false;
35
+ }
36
+
37
+ return result;
38
+ }
39
+
40
+ /**
41
+ * Get a parameter passed in URL by name
42
+ * @param name parameter name
43
+ * @return parameter value decoded if needed
44
+ */
18
45
  function getUrlParam(name) {
19
46
  let url = window.location.href;
20
47
  name = name.replace(/[\[\]]/g, "\\$&");
21
- let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
48
+ // Fixed streams playback with '#' char in name (test#m1) #WCS-3655
49
+ let regex = new RegExp("[?&]" + name + "(=([^&]*)|&|$)"),
22
50
  results = regex.exec(url);
23
51
  if (!results) return null;
24
52
  if (!results[2]) return '';
25
- return decodeURIComponent(results[2].replace(/\+/g, " "));
53
+ let value = results[2];
54
+ if (isEncoded(value)) {
55
+ value = decodeURIComponent(value);
56
+ }
57
+ // Add workaround to play RTSP streams with '@' char in password #WCS-3655
58
+ if (value.startsWith("rtsp://") || value.startsWith("rtmp://")) {
59
+ return value.replace(/\@(?=.*\@)/g, '%40');
60
+ }
61
+ return value;
26
62
  }
27
63
 
28
64
  /**
29
65
  * Resize video object to fit parent div.
30
66
  * Div structure: div WxH -> div wrapper (display) -> video
31
67
  * @param video HTML element from resize event target
68
+ * @param width optional width to scale
69
+ * @param height optional height to scale
32
70
  */
33
71
  function resizeVideo(video, width, height) {
34
72
  if (!video.parentNode) {
@@ -62,6 +100,14 @@ function resizeVideo(video, width, height) {
62
100
  }
63
101
 
64
102
 
103
+ /**
104
+ * Helper function to resize video
105
+ * @param videoWidth source video width
106
+ * @param videoHeight source video height
107
+ * @param dstWidth destination video width
108
+ * @param dstHeight destination video height
109
+ * @return new width and height
110
+ */
65
111
  function downScaleToFitSize(videoWidth, videoHeight, dstWidth, dstHeight) {
66
112
  let newWidth, newHeight;
67
113
  let videoRatio = videoWidth / videoHeight;
@@ -6,6 +6,8 @@ var remoteVideo;
6
6
  var extensionId = "nlbaajplpmleofphigmgaifhoikjmbkg";
7
7
  var extensionNotInstalled;
8
8
 
9
+ var askExtension = getUrlParam("askExtension") || false;
10
+
9
11
  function init_page() {
10
12
  //init api
11
13
  try {
@@ -29,20 +31,22 @@ function init_page() {
29
31
 
30
32
  } else if (Browser.isChrome() && !Browser.isAndroid() && !Browser.isiOS()) {
31
33
  interval = setInterval(function() {
32
- chrome.runtime.sendMessage(extensionId, {type: "isInstalled"}, function (response) {
33
- if (chrome.runtime.lastError) { //WCS-2369 - cacth runtime.lastError
34
- (inIframe()) ? $("#installFromMarket").show() : $("#installExtensionButton").show();
35
- clearInterval(interval);
36
- onExtensionAvailable();
37
- $('#woChromeExtension').prop('checked', true);
38
- $('#woChromeExtension').prop('disabled', true);
39
- extensionNotInstalled = true;
40
- } else {
41
- $("#extension").hide();
34
+ try {
35
+ chrome.runtime.sendMessage(extensionId, {type: "isInstalled"}, function (response) {
36
+ if (chrome.runtime.lastError) { //WCS-2369 - catch runtime.lastError
37
+ onExtensionNotFound();
38
+ } else {
39
+ $("#extension").hide();
40
+ onExtensionAvailable();
41
+ }
42
42
  clearInterval(interval);
43
- onExtensionAvailable();
44
- }
45
- });
43
+ });
44
+ } catch (e) {
45
+ // Catch chrome.runtime.sendMessage undefined exception #WCS-3638
46
+ console.log("Can't detect screen sharing extension: "+e);
47
+ onExtensionNotFound();
48
+ clearInterval(interval);
49
+ }
46
50
  }, 500);
47
51
  } else if(isSafariMacOS()) {
48
52
  $("#extension").hide();
@@ -84,6 +88,22 @@ function isSafariMacOS() {
84
88
  return Browser.isSafari() && !Browser.isAndroid() && !Browser.isiOS();
85
89
  }
86
90
 
91
+ function onExtensionNotFound() {
92
+ if (askExtension === true) {
93
+ if (inIframe()) {
94
+ $("#installFromMarket").show();
95
+ } else {
96
+ $("#installExtensionButton").show();
97
+ }
98
+ } else {
99
+ $("#extension").hide();
100
+ }
101
+ onExtensionAvailable();
102
+ $('#woChromeExtension').prop('checked', true);
103
+ $('#woChromeExtension').prop('disabled', true);
104
+ extensionNotInstalled = true;
105
+ }
106
+
87
107
  function onExtensionAvailable() {
88
108
  localVideo = document.getElementById("localVideo");
89
109
  remoteVideo = document.getElementById("remoteVideo");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashphoner/websdk",
3
- "version": "2.0.225",
3
+ "version": "2.0.227",
4
4
  "description": "Official Flashphoner WebCallServer WebSDK package",
5
5
  "main": "./src/flashphoner-core.js",
6
6
  "types": "./src/flashphoner-core.d.ts",