@flashphoner/websdk 2.0.226 → 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.
package/docTemplate/README.md
CHANGED
|
@@ -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()
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|