@flashphoner/websdk 2.0.223 → 2.0.225
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 +1 -1
- package/examples/demo/streaming/embed_player/images/stop.png +0 -0
- package/examples/demo/streaming/embed_player/player.css +40 -428
- package/examples/demo/streaming/embed_player/player.html +5 -63
- package/examples/demo/streaming/embed_player/player.js +235 -377
- package/examples/demo/streaming/embed_player/sample.html +0 -4
- package/examples/demo/streaming/embed_player/utils.js +80 -0
- package/examples/demo/streaming/player/player.js +40 -7
- package/flashphoner-no-flash.js +920 -2894
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +793 -2599
- package/flashphoner-no-webrtc.min.js +2 -2
- package/flashphoner-no-wsplayer.js +913 -2585
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api.js +112 -22
- package/flashphoner-room-api.min.js +2 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +843 -2843
- package/flashphoner-temasys-flash-websocket.js +842 -2842
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +912 -2584
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +920 -2894
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/flashphoner-core.js +11 -3
- package/src/media-source-media-provider.js +1 -1
- package/src/util.js +40 -2
- package/src/webrtc-media-provider.js +60 -16
|
@@ -60,10 +60,6 @@
|
|
|
60
60
|
<label class="check-label" for="MSE"><input id="MSE" type="checkbox" checked/>
|
|
61
61
|
MSE</label>
|
|
62
62
|
</li>
|
|
63
|
-
<li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
|
|
64
|
-
<label class="check-label" for="WSPlayer"><input id="WSPlayer" type="checkbox" checked/>
|
|
65
|
-
WSPlayer</label>
|
|
66
|
-
</li>
|
|
67
63
|
</ul>
|
|
68
64
|
</div>
|
|
69
65
|
</div>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//Set WCS URL
|
|
2
|
+
function setURL() {
|
|
3
|
+
let proto;
|
|
4
|
+
let url;
|
|
5
|
+
let port;
|
|
6
|
+
if (window.location.protocol == "http:") {
|
|
7
|
+
proto = "ws://";
|
|
8
|
+
port = "8080";
|
|
9
|
+
} else {
|
|
10
|
+
proto = "wss://";
|
|
11
|
+
port = "8443";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
url = proto + window.location.hostname + ":" + port;
|
|
15
|
+
return url;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getUrlParam(name) {
|
|
19
|
+
let url = window.location.href;
|
|
20
|
+
name = name.replace(/[\[\]]/g, "\\$&");
|
|
21
|
+
let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
|
22
|
+
results = regex.exec(url);
|
|
23
|
+
if (!results) return null;
|
|
24
|
+
if (!results[2]) return '';
|
|
25
|
+
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resize video object to fit parent div.
|
|
30
|
+
* Div structure: div WxH -> div wrapper (display) -> video
|
|
31
|
+
* @param video HTML element from resize event target
|
|
32
|
+
*/
|
|
33
|
+
function resizeVideo(video, width, height) {
|
|
34
|
+
if (!video.parentNode) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (video instanceof HTMLCanvasElement) {
|
|
38
|
+
video.videoWidth = video.width;
|
|
39
|
+
video.videoHeight = video.height;
|
|
40
|
+
}
|
|
41
|
+
let display = video.parentNode;
|
|
42
|
+
let parentSize = {
|
|
43
|
+
w: display.parentNode.clientWidth,
|
|
44
|
+
h: display.parentNode.clientHeight
|
|
45
|
+
};
|
|
46
|
+
let newSize;
|
|
47
|
+
if (width && height) {
|
|
48
|
+
newSize = downScaleToFitSize(width, height, parentSize.w, parentSize.h);
|
|
49
|
+
} else {
|
|
50
|
+
newSize = downScaleToFitSize(video.videoWidth, video.videoHeight, parentSize.w, parentSize.h);
|
|
51
|
+
}
|
|
52
|
+
display.style.width = newSize.w + "px";
|
|
53
|
+
display.style.height = newSize.h + "px";
|
|
54
|
+
|
|
55
|
+
//vertical align
|
|
56
|
+
let margin = 0;
|
|
57
|
+
if (parentSize.h - newSize.h > 1) {
|
|
58
|
+
margin = Math.floor((parentSize.h - newSize.h) / 2);
|
|
59
|
+
}
|
|
60
|
+
display.style.margin = margin + "px auto";
|
|
61
|
+
console.log("Resize from " + video.videoWidth + "x" + video.videoHeight + " to " + display.offsetWidth + "x" + display.offsetHeight);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
function downScaleToFitSize(videoWidth, videoHeight, dstWidth, dstHeight) {
|
|
66
|
+
let newWidth, newHeight;
|
|
67
|
+
let videoRatio = videoWidth / videoHeight;
|
|
68
|
+
let dstRatio = dstWidth / dstHeight;
|
|
69
|
+
if (dstRatio > videoRatio) {
|
|
70
|
+
newHeight = dstHeight;
|
|
71
|
+
newWidth = Math.floor(videoRatio * dstHeight);
|
|
72
|
+
} else {
|
|
73
|
+
newWidth = dstWidth;
|
|
74
|
+
newHeight = Math.floor(dstWidth / videoRatio);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
w: newWidth,
|
|
78
|
+
h: newHeight
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -14,6 +14,8 @@ var resolution = getUrlParam("resolution");
|
|
|
14
14
|
var mediaProvider = getUrlParam("mediaProvider") || null;
|
|
15
15
|
var mseCutByIFrameOnly = getUrlParam("mseCutByIFrameOnly");
|
|
16
16
|
|
|
17
|
+
var useVideoControls = false;
|
|
18
|
+
|
|
17
19
|
function init_page() {
|
|
18
20
|
|
|
19
21
|
//init api
|
|
@@ -51,6 +53,14 @@ function init_page() {
|
|
|
51
53
|
}
|
|
52
54
|
}).slider("disable");
|
|
53
55
|
onStopped();
|
|
56
|
+
if (Browser.isSafari()) {
|
|
57
|
+
// Enable video controls for fullscreen mode to work in Safari 16
|
|
58
|
+
useVideoControls = true;
|
|
59
|
+
$("#fullScreen").hide();
|
|
60
|
+
if (Browser.isiOS()) {
|
|
61
|
+
$("#volume").hide();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
54
64
|
if (autoplay) {
|
|
55
65
|
// We can start autoplay with muted audio only, so set volume slider to 0 #WCS-2425
|
|
56
66
|
$("#volumeControl").slider('value', 0);
|
|
@@ -86,8 +96,8 @@ function playBtnClick() {
|
|
|
86
96
|
$("#streamName").prop('disabled', true);
|
|
87
97
|
if (Flashphoner.getMediaProviders()[0] === "WSPlayer") {
|
|
88
98
|
Flashphoner.playFirstSound();
|
|
89
|
-
} else if (Browser.
|
|
90
|
-
Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL).then(function() {
|
|
99
|
+
} else if (Browser.isSafari()) {
|
|
100
|
+
Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL, useVideoControls).then(function() {
|
|
91
101
|
start();
|
|
92
102
|
}).catch(function () {
|
|
93
103
|
onStopped();
|
|
@@ -101,6 +111,7 @@ function playBtnClick() {
|
|
|
101
111
|
function start() {
|
|
102
112
|
var url = $('#url').val();
|
|
103
113
|
//check if we already have session
|
|
114
|
+
$("#preloader").show();
|
|
104
115
|
if (Flashphoner.getSessions().length > 0) {
|
|
105
116
|
var session = Flashphoner.getSessions()[0];
|
|
106
117
|
if (session.getServerUrl() == url) {
|
|
@@ -134,7 +145,7 @@ function playStream(session) {
|
|
|
134
145
|
var options = {
|
|
135
146
|
name: streamName,
|
|
136
147
|
display: remoteVideo,
|
|
137
|
-
|
|
148
|
+
useControls: useVideoControls
|
|
138
149
|
};
|
|
139
150
|
if (Flashphoner.getMediaProviders()[0] === "MSE" && mseCutByIFrameOnly) {
|
|
140
151
|
options.mediaConnectionConstraints = {
|
|
@@ -152,7 +163,6 @@ function playStream(session) {
|
|
|
152
163
|
options.unmutePlayOnStart = false;
|
|
153
164
|
}
|
|
154
165
|
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function (stream) {
|
|
155
|
-
$("#preloader").show();
|
|
156
166
|
var video = document.getElementById(stream.id());
|
|
157
167
|
if (!video.hasListeners) {
|
|
158
168
|
video.hasListeners = true;
|
|
@@ -171,17 +181,40 @@ function playStream(session) {
|
|
|
171
181
|
}
|
|
172
182
|
});
|
|
173
183
|
}
|
|
184
|
+
if (useVideoControls && Browser.isSafariWebRTC()) {
|
|
185
|
+
// iOS hack when using standard controls to leave fullscreen mode
|
|
186
|
+
var needRestart = false;
|
|
187
|
+
video.addEventListener("pause", function () {
|
|
188
|
+
if(needRestart) {
|
|
189
|
+
console.log("Video paused after fullscreen, continue...");
|
|
190
|
+
video.play();
|
|
191
|
+
needRestart = false;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
video.addEventListener("webkitendfullscreen", function () {
|
|
195
|
+
video.play();
|
|
196
|
+
needRestart = true;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// Hide preloader when playing video
|
|
200
|
+
video.addEventListener("playing", function () {
|
|
201
|
+
$("#preloader").hide();
|
|
202
|
+
});
|
|
174
203
|
}
|
|
175
204
|
}).on(STREAM_STATUS.PLAYING, function (stream) {
|
|
176
|
-
|
|
205
|
+
// Android Firefox may pause stream playback via MSE even if video element is muted
|
|
206
|
+
if (Flashphoner.getMediaProviders()[0] == "MSE" && autoplay && Browser.isAndroidFirefox()) {
|
|
207
|
+
let video = document.getElementById(stream.id());
|
|
208
|
+
if (video && video.paused) {
|
|
209
|
+
video.play();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
177
212
|
setStatus(stream.status());
|
|
178
213
|
onStarted(stream);
|
|
179
214
|
}).on(STREAM_STATUS.STOPPED, function () {
|
|
180
|
-
$("#preloader").hide();
|
|
181
215
|
setStatus(STREAM_STATUS.STOPPED);
|
|
182
216
|
onStopped();
|
|
183
217
|
}).on(STREAM_STATUS.FAILED, function(stream) {
|
|
184
|
-
$("#preloader").hide();
|
|
185
218
|
setStatus(STREAM_STATUS.FAILED, stream);
|
|
186
219
|
onStopped();
|
|
187
220
|
}).on(STREAM_EVENT, function(streamEvent){
|