@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
|
@@ -1,102 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const HTML_FULLSCREEN_EXIT='<svg height="100%" version="1.1" viewBox="0 0 36 36" width="100%"><g class="ytp-fullscreen-button-corner-2"><path style="fill: #fff;" d="m 14,14 -4,0 0,2 6,0 0,-6 -2,0 0,4 0,0 z"></path></g><g><path style="fill: #fff;" d="m 22,14 0,-4 -2,0 0,6 6,0 0,-2 -4,0 0,0 z"></path></g><g><path style="fill: #fff;" d="m 20,26 2,0 0,-4 4,0 0,-2 -6,0 0,6 0,0 z"></path></g><g><path style="fill: #fff;" d="m 10,22 4,0 0,4 2,0 0,-6 -6,0 0,2 0,0 z"></path></g></svg>';
|
|
20
|
-
let firstUnmuted = true;
|
|
1
|
+
const SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
|
|
2
|
+
const STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;
|
|
3
|
+
const STREAM_EVENT = Flashphoner.constants.STREAM_EVENT;
|
|
4
|
+
const STREAM_EVENT_TYPE = Flashphoner.constants.STREAM_EVENT_TYPE;
|
|
5
|
+
const PRELOADER_URL = "../../dependencies/media/preloader.mp4";
|
|
6
|
+
const Browser = Flashphoner.Browser;
|
|
7
|
+
let remoteVideo;
|
|
8
|
+
let playingStream;
|
|
9
|
+
let isStopped = true;
|
|
10
|
+
|
|
11
|
+
let autoplay = eval(getUrlParam("autoplay")) || false;
|
|
12
|
+
let resolution = getUrlParam("resolution");
|
|
13
|
+
let mediaProviders = getUrlParam("mediaProviders") || "";
|
|
14
|
+
let streamName = getUrlParam("streamName") || "streamName";
|
|
15
|
+
let urlServer = getUrlParam("urlServer") || setURL();
|
|
16
|
+
|
|
17
|
+
// Will always use a standard video controls
|
|
18
|
+
let useVideoControls = true;
|
|
21
19
|
|
|
22
20
|
function init_page() {
|
|
23
|
-
//video display
|
|
24
|
-
remoteVideo = document.getElementById("remoteVideo");
|
|
25
|
-
$('#remoteVideo').videoPlayer({
|
|
26
|
-
'playerWidth': 1,
|
|
27
|
-
'videoClass': 'video'
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
onStopped();
|
|
31
|
-
|
|
32
21
|
//init api
|
|
33
22
|
try {
|
|
34
|
-
Flashphoner.init({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
preferredMediaProviders: mediaProviders && mediaProviders !== "" ? mediaProviders.split(','): []
|
|
38
|
-
});
|
|
39
|
-
} catch (e) {
|
|
40
|
-
$("#error_output").text(e.message);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (Flashphoner.getMediaProviders()[0] === "WSPlayer") {
|
|
44
|
-
if (Browser.isiOS()) {
|
|
45
|
-
$(".fullscreen").hide();
|
|
23
|
+
Flashphoner.init({ preferredMediaProviders: mediaProviders && mediaProviders !== "" ? mediaProviders.split(','): [] });
|
|
24
|
+
if (Flashphoner.getMediaProviders()[0] == "WSPlayer") {
|
|
25
|
+
throw new Error("The WSPlayer mediaProvider is deprecated");
|
|
46
26
|
}
|
|
27
|
+
} catch(e) {
|
|
28
|
+
document.getElementById("status").innerHTML = e.message;
|
|
29
|
+
hideItem('preloader');
|
|
30
|
+
centralButton.hide();
|
|
31
|
+
return;
|
|
47
32
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
$(".play-pause").click();
|
|
33
|
+
|
|
34
|
+
// Save video display element
|
|
35
|
+
remoteVideo = document.getElementById("remoteVideo");
|
|
36
|
+
|
|
37
|
+
// Init page elements
|
|
38
|
+
onStopped();
|
|
39
|
+
|
|
40
|
+
// Start playback if autoplay required
|
|
41
|
+
if (autoplay) {
|
|
42
|
+
centralButton.click();
|
|
59
43
|
}
|
|
60
44
|
}
|
|
61
45
|
|
|
62
|
-
function onStarted(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
$(".play-pause").prop('disabled', false);
|
|
66
|
-
$(".fullscreen").prop('disabled', false);
|
|
67
|
-
stream.setVolume(currentVolumeValue);
|
|
46
|
+
function onStarted() {
|
|
47
|
+
isStopped = false;
|
|
48
|
+
centralButton.prepareToStop();
|
|
68
49
|
}
|
|
69
50
|
|
|
70
51
|
function onStopped() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!$('.play-pause').prop('disabled')) {
|
|
75
|
-
if (stopped) {
|
|
76
|
-
start();
|
|
77
|
-
$('.play-pause').addClass('pause').removeClass('play').prop('disabled', true);
|
|
78
|
-
$('#play').css('display', 'none');
|
|
79
|
-
} else {
|
|
80
|
-
if (stream) {
|
|
81
|
-
stream.stop();
|
|
82
|
-
}
|
|
83
|
-
$('.play-pause').addClass('play').removeClass('pause').prop('disabled', true);
|
|
84
|
-
$("#preloader").hide();
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
$(".play-pause").addClass('play').removeClass('pause').prop('disabled', false);
|
|
89
|
-
$(".fullscreen").prop('disabled', true);
|
|
90
|
-
$("#preloader").hide();
|
|
52
|
+
isStopped = true;
|
|
53
|
+
hideItem('preloader');
|
|
54
|
+
centralButton.prepareToStart(playBtnClick);
|
|
91
55
|
}
|
|
92
56
|
|
|
93
|
-
function
|
|
94
|
-
|
|
57
|
+
function playBtnClick() {
|
|
58
|
+
if (isStopped) {
|
|
59
|
+
centralButton.hide();
|
|
60
|
+
start();
|
|
61
|
+
} else {
|
|
62
|
+
if (playingStream) {
|
|
63
|
+
playingStream.stop();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
95
67
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
68
|
+
function start() {
|
|
69
|
+
if (!Browser.isChrome()) {
|
|
70
|
+
// Display the custom preloader in non-Chromium browser
|
|
71
|
+
showItem('preloader');
|
|
72
|
+
}
|
|
73
|
+
if (Browser.isSafari()) {
|
|
74
|
+
Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL, useVideoControls).then(function() {
|
|
100
75
|
createSession();
|
|
101
76
|
}).catch(function() {
|
|
102
77
|
onStopped();
|
|
@@ -109,13 +84,15 @@ function start() {
|
|
|
109
84
|
function createSession() {
|
|
110
85
|
//check if we already have session
|
|
111
86
|
if (Flashphoner.getSessions().length > 0) {
|
|
112
|
-
|
|
87
|
+
let session = Flashphoner.getSessions()[0];
|
|
113
88
|
playStream(session);
|
|
114
89
|
return;
|
|
115
90
|
}
|
|
91
|
+
// In Chromium browsers we need a custom preloader for a new session only
|
|
92
|
+
showItem('preloader');
|
|
116
93
|
//create session
|
|
117
94
|
console.log("Create new session with url " + urlServer);
|
|
118
|
-
|
|
95
|
+
let mediaOptions = {"iceServers": [{'url': 'turn:turn.flashphoner.com:443?transport=tcp', 'username': 'flashphoner', 'credential': 'coM77EMrV7Cwhyan'}]};
|
|
119
96
|
Flashphoner.createSession({urlServer: urlServer, mediaOptions: mediaOptions}).on(SESSION_STATUS.ESTABLISHED, function (session) {
|
|
120
97
|
setStatus(session.status());
|
|
121
98
|
//session connected, start playback
|
|
@@ -130,337 +107,218 @@ function createSession() {
|
|
|
130
107
|
}
|
|
131
108
|
|
|
132
109
|
function playStream(session) {
|
|
133
|
-
|
|
110
|
+
let playWidth = 0;
|
|
111
|
+
let platHeight = 0;
|
|
112
|
+
let options = {
|
|
134
113
|
name: streamName,
|
|
135
114
|
display: remoteVideo,
|
|
136
|
-
|
|
115
|
+
useControls: useVideoControls
|
|
137
116
|
};
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
117
|
+
if (resolution) {
|
|
118
|
+
playWidth = resolution.split("x")[0];
|
|
119
|
+
playHeight = resolution.split("x")[1];
|
|
120
|
+
options.constraints = {
|
|
121
|
+
video: {
|
|
122
|
+
width: playWidth,
|
|
123
|
+
height: playHeight
|
|
124
|
+
},
|
|
125
|
+
audio: true
|
|
126
|
+
};
|
|
144
127
|
}
|
|
145
128
|
if (autoplay) {
|
|
146
129
|
options.unmutePlayOnStart = false;
|
|
147
130
|
}
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
playingStream = session.createStream(options).on(STREAM_STATUS.PENDING, function (stream) {
|
|
132
|
+
if (Browser.isChrome()) {
|
|
133
|
+
// Hide a custom preloader in Chrome because there is a standard one with standard controls
|
|
134
|
+
hideItem('preloader');
|
|
135
|
+
}
|
|
136
|
+
let video = document.getElementById(stream.id());
|
|
150
137
|
if (!video.hasListeners) {
|
|
151
138
|
video.hasListeners = true;
|
|
152
|
-
video
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
resizeVideo(event.target);
|
|
159
|
-
} else {
|
|
160
|
-
// Change aspect ratio to prevent video stretching
|
|
161
|
-
var ratio = streamResolution.width / streamResolution.height;
|
|
162
|
-
var newHeight = Math.floor(options.playWidth / ratio);
|
|
163
|
-
resizeVideo(event.target, options.playWidth, newHeight);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
139
|
+
setResizeHandler(video, stream, playWidth);
|
|
140
|
+
if (Browser.isSafariWebRTC()) {
|
|
141
|
+
setWebkitEventHandlers(video);
|
|
142
|
+
} else {
|
|
143
|
+
setEventHandlers(video);
|
|
144
|
+
}
|
|
166
145
|
}
|
|
167
146
|
}).on(STREAM_STATUS.PLAYING, function (stream) {
|
|
168
|
-
|
|
169
|
-
|
|
147
|
+
// Android Firefox may pause stream playback via MSE even if video element is muted
|
|
148
|
+
if (Flashphoner.getMediaProviders()[0] == "MSE" && autoplay && Browser.isAndroidFirefox()) {
|
|
149
|
+
let video = document.getElementById(stream.id());
|
|
150
|
+
if (video && video.paused) {
|
|
151
|
+
video.play();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
setStatus(STREAM_STATUS.PLAYING);
|
|
155
|
+
onStarted();
|
|
170
156
|
}).on(STREAM_STATUS.STOPPED, function () {
|
|
171
157
|
setStatus(STREAM_STATUS.STOPPED);
|
|
172
158
|
onStopped();
|
|
173
|
-
}).on(STREAM_STATUS.FAILED, function
|
|
174
|
-
setStatus(STREAM_STATUS.FAILED);
|
|
159
|
+
}).on(STREAM_STATUS.FAILED, function(stream) {
|
|
160
|
+
setStatus(STREAM_STATUS.FAILED, stream);
|
|
175
161
|
onStopped();
|
|
176
|
-
}).on(
|
|
177
|
-
|
|
162
|
+
}).on(STREAM_EVENT, function(streamEvent){
|
|
163
|
+
if (STREAM_EVENT_TYPE.NOT_ENOUGH_BANDWIDTH === streamEvent.type) {
|
|
164
|
+
let info = streamEvent.payload.info.split("/");
|
|
165
|
+
let remoteBitrate = info[0];
|
|
166
|
+
let networkBandwidth = info[1];
|
|
167
|
+
console.log("Not enough bandwidth, consider using lower video resolution or bitrate. Bandwidth " + (Math.round(networkBandwidth / 1000)) + " bitrate " + (Math.round(remoteBitrate / 1000)));
|
|
168
|
+
} else if (STREAM_EVENT_TYPE.RESIZE === streamEvent.type) {
|
|
169
|
+
console.log("New video size: " + streamEvent.payload.streamerVideoWidth + "x" + streamEvent.payload.streamerVideoHeight);
|
|
170
|
+
}
|
|
178
171
|
});
|
|
179
|
-
|
|
172
|
+
playingStream.play();
|
|
180
173
|
}
|
|
181
174
|
|
|
182
175
|
//show connection or remote stream status
|
|
183
|
-
function setStatus(status) {
|
|
184
|
-
|
|
185
|
-
statusField.removeClass("text-success").removeClass("text-muted").removeClass("text-danger");
|
|
176
|
+
function setStatus(status, stream) {
|
|
177
|
+
let statusField = document.getElementById("status");
|
|
186
178
|
if (status == "PLAYING" || status == "ESTABLISHED" || status == "STOPPED") {
|
|
187
179
|
//don't display status word because we have this indication on UI
|
|
188
|
-
statusField.
|
|
180
|
+
statusField.innerHTML = "";
|
|
189
181
|
} else if (status == "DISCONNECTED") {
|
|
190
|
-
statusField.
|
|
191
|
-
statusField.addClass("text-muted");
|
|
182
|
+
statusField.innerHTML = status;
|
|
192
183
|
} else if (status == "FAILED") {
|
|
193
|
-
statusField.
|
|
194
|
-
|
|
184
|
+
statusField.innerHTML = status;
|
|
185
|
+
if (stream && stream.getInfo() !== "") {
|
|
186
|
+
statusField.innerHTML = status + ": " + stream.getInfo();
|
|
187
|
+
}
|
|
195
188
|
}
|
|
196
189
|
}
|
|
197
190
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
191
|
+
// Resize event handler
|
|
192
|
+
function setResizeHandler(video, stream, playWidth) {
|
|
193
|
+
video.addEventListener('resize', function (event) {
|
|
194
|
+
let streamResolution = stream.videoResolution();
|
|
195
|
+
if (Object.keys(streamResolution).length === 0) {
|
|
196
|
+
resizeVideo(event.target);
|
|
204
197
|
} else {
|
|
205
|
-
|
|
198
|
+
// Change aspect ratio to prevent video stretching
|
|
199
|
+
let ratio = streamResolution.width / streamResolution.height;
|
|
200
|
+
let newHeight = Math.floor(playWidth / ratio);
|
|
201
|
+
resizeVideo(event.target, playWidth, newHeight);
|
|
206
202
|
}
|
|
207
203
|
});
|
|
208
|
-
return valid;
|
|
209
|
-
|
|
210
|
-
function highlightInput(input) {
|
|
211
|
-
input.closest('.form-group').addClass("has-error");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function removeHighlight(input) {
|
|
215
|
-
input.closest('.form-group').removeClass("has-error");
|
|
216
|
-
}
|
|
217
204
|
}
|
|
218
205
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
206
|
+
// iOS/MacOS handlers for fullscreen issues
|
|
207
|
+
function setWebkitEventHandlers(video) {
|
|
208
|
+
let needRestart = false;
|
|
209
|
+
let isFullscreen = false;
|
|
210
|
+
// Hide custom preloader
|
|
211
|
+
video.addEventListener('playing', function () {
|
|
212
|
+
hideItem('preloader');
|
|
213
|
+
});
|
|
214
|
+
// Use webkitbeginfullscreen event to detect full screen mode in iOS Safari
|
|
215
|
+
video.addEventListener("webkitbeginfullscreen", function () {
|
|
216
|
+
isFullscreen = true;
|
|
217
|
+
});
|
|
218
|
+
video.addEventListener("pause", function () {
|
|
219
|
+
if (needRestart) {
|
|
220
|
+
console.log("Video paused after fullscreen, continue...");
|
|
221
|
+
video.play();
|
|
222
|
+
needRestart = false;
|
|
223
|
+
} else if (!(isFullscreen || document.webkitFullscreenElement)) {
|
|
224
|
+
// Stop stream by standard play/pause control
|
|
225
|
+
playingStream.stop();
|
|
233
226
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
227
|
+
});
|
|
228
|
+
video.addEventListener("webkitendfullscreen", function () {
|
|
229
|
+
video.play();
|
|
230
|
+
needRestart = true;
|
|
231
|
+
isFullscreen = false;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
238
234
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
235
|
+
function setEventHandlers(video) {
|
|
236
|
+
// Hide custom preloader
|
|
237
|
+
video.addEventListener('playing', function () {
|
|
238
|
+
hideItem('preloader');
|
|
239
|
+
});
|
|
240
|
+
// Use standard pause control to stop playback
|
|
241
|
+
video.addEventListener("pause", function () {
|
|
242
|
+
if (!(document.fullscreenElement || document.mozFullscreenElement)) {
|
|
243
|
+
// Stop stream by standard play/pause control if we're not in fullscreen
|
|
244
|
+
playingStream.stop();
|
|
244
245
|
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
245
248
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
// Object to manage central Play/Stop button
|
|
250
|
+
const centralButton = {
|
|
251
|
+
timer: null,
|
|
252
|
+
displayed: false,
|
|
253
|
+
display: function(timeout = 0) {
|
|
254
|
+
showItem('play');
|
|
255
|
+
centralButton.displayed = true;
|
|
256
|
+
if (timeout > 0 && !centralButton.timer) {
|
|
257
|
+
centralButton.timer = setTimeout(function() {
|
|
258
|
+
centralButton.hide();
|
|
259
|
+
}, timeout);
|
|
249
260
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
261
|
+
},
|
|
262
|
+
displayToggle: function(timeout) {
|
|
263
|
+
if(!centralButton.displayed) {
|
|
264
|
+
centralButton.display(timeout);
|
|
265
|
+
} else {
|
|
266
|
+
centralButton.hide();
|
|
253
267
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
268
|
+
},
|
|
269
|
+
setAction: function(action) {
|
|
270
|
+
document.getElementById('play').onclick = action;
|
|
271
|
+
},
|
|
272
|
+
setView: function(view) {
|
|
273
|
+
let button = document.getElementById('play');
|
|
274
|
+
let image = button.querySelector('img');
|
|
275
|
+
if (view === "play") {
|
|
276
|
+
button.classList.remove('stop');
|
|
277
|
+
button.classList.add('play');
|
|
278
|
+
image.src = 'images/play.png';
|
|
279
|
+
} else if (view === "stop") {
|
|
280
|
+
button.classList.remove('play');
|
|
281
|
+
button.classList.add('stop');
|
|
282
|
+
image.src = 'images/stop.png';
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
hide: function() {
|
|
286
|
+
hideItem('play');
|
|
287
|
+
centralButton.displayed = false;
|
|
288
|
+
centralButton.stopTimer();
|
|
289
|
+
},
|
|
290
|
+
stopTimer: function() {
|
|
291
|
+
if (centralButton.timer) {
|
|
292
|
+
clearTimeout(centralButton.timer);
|
|
293
|
+
centralButton.timer = null;
|
|
260
294
|
}
|
|
295
|
+
},
|
|
296
|
+
click: function() {
|
|
297
|
+
document.getElementById('play').click();
|
|
298
|
+
},
|
|
299
|
+
prepareToStart: function(action) {
|
|
300
|
+
centralButton.stopTimer();
|
|
301
|
+
centralButton.setView("play");
|
|
302
|
+
centralButton.display();
|
|
303
|
+
centralButton.setAction(action);
|
|
304
|
+
},
|
|
305
|
+
prepareToStop: function() {
|
|
306
|
+
centralButton.setView("stop");
|
|
307
|
+
centralButton.hide();
|
|
261
308
|
}
|
|
309
|
+
};
|
|
262
310
|
|
|
263
|
-
|
|
311
|
+
// Helper functions to display/hide an element
|
|
312
|
+
function showItem(id) {
|
|
313
|
+
let item = document.getElementById(id);
|
|
314
|
+
if (item) {
|
|
315
|
+
item.style.display = "block";
|
|
316
|
+
}
|
|
264
317
|
}
|
|
265
318
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
if (options) {
|
|
274
|
-
$.extend(settings, options);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return this.each(function () {
|
|
278
|
-
var $this = $(this);
|
|
279
|
-
var $settings = settings;
|
|
280
|
-
var $that = $this.parent('.' + $settings.videoClass);
|
|
281
|
-
$that.find('.player').css({
|
|
282
|
-
'width': ($settings.playerWidth * 100) + '%',
|
|
283
|
-
'left': ((100 - $settings.playerWidth * 100) / 2) + '%'
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
var $mclicking = false,
|
|
287
|
-
$vclicking = false,
|
|
288
|
-
$volhover = false,
|
|
289
|
-
$clearTimeout;
|
|
290
|
-
y = 0;
|
|
291
|
-
|
|
292
|
-
$that.bind('selectstart', function () {
|
|
293
|
-
return false;
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
$that.find('.play-pause').bind('click', function () {
|
|
297
|
-
// If playing, etc, change classes to show pause or play button
|
|
298
|
-
if (!$(this).prop('disabled')) {
|
|
299
|
-
if (stopped) {
|
|
300
|
-
start();
|
|
301
|
-
$(this).addClass('pause').removeClass('play').prop('disabled', true);
|
|
302
|
-
$('#play').css('display', 'none');
|
|
303
|
-
} else {
|
|
304
|
-
if (stream) {
|
|
305
|
-
stream.stop();
|
|
306
|
-
}
|
|
307
|
-
$(this).addClass('play').removeClass('pause').prop('disabled', true);
|
|
308
|
-
$("#preloader").hide();
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
$that.bind('click', function () {
|
|
314
|
-
if ( !stopped ) {
|
|
315
|
-
if ($clearTimeout) {
|
|
316
|
-
clearTimeout($clearTimeout);
|
|
317
|
-
}
|
|
318
|
-
$that.find('.player').stop(true, false).animate({'opacity': '1'}, 0.5);
|
|
319
|
-
$clearTimeout = setTimeout(function() {
|
|
320
|
-
$that.find('.player').stop(true, false).animate({'opacity': '0'}, 0.5);
|
|
321
|
-
}, 5000);
|
|
322
|
-
};
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
$that.find('.volume').hover(function () {
|
|
326
|
-
$volhover = true;
|
|
327
|
-
}, function () {
|
|
328
|
-
$volhover = false;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
$('body, html').bind('mousemove', function (e) {
|
|
332
|
-
if ( !stopped ) {
|
|
333
|
-
$that.hover(function () {
|
|
334
|
-
$that.find('.player').stop(true, false).animate({'opacity': '1'}, 0.5);
|
|
335
|
-
}, function () {
|
|
336
|
-
$that.find('.player').stop(true, false).animate({'opacity': '0'}, 0.5);
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
if (!$volhover) {
|
|
340
|
-
$that.find('.volume-holder').stop(true, false).fadeOut(100);
|
|
341
|
-
$that.find('.volume-icon').removeClass('volume-icon-hover');
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
$that.find('.volume-icon').addClass('volume-icon-hover');
|
|
345
|
-
$that.find('.volume-holder').fadeIn(100);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// Requests fullscreen based on browser.
|
|
350
|
-
$('.fullscreenBtn').click(function () {
|
|
351
|
-
if ( stream ) {
|
|
352
|
-
stream.fullScreen();
|
|
353
|
-
};
|
|
354
|
-
});
|
|
355
|
-
var init = $( "#slider" ).slider({
|
|
356
|
-
value: 50,
|
|
357
|
-
orientation: "horizontal",
|
|
358
|
-
range: "min",
|
|
359
|
-
slide: function( event, ui ) {
|
|
360
|
-
valueRange()
|
|
361
|
-
},
|
|
362
|
-
stop: function( event, ui ) {
|
|
363
|
-
valueRange()
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
valueRange();
|
|
367
|
-
|
|
368
|
-
var prevVol=1;
|
|
369
|
-
function valueRange() {
|
|
370
|
-
currentVolumeValue = $( "#slider" ).slider( "value" );
|
|
371
|
-
if (setVolume(currentVolumeValue, true)) {
|
|
372
|
-
// Save previous volume state to set when stream is unmuted by button
|
|
373
|
-
prevVol = currentVolumeValue ? currentVolumeValue : 1;
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
//mute unmute volume on click
|
|
379
|
-
$('.volume').on('click', function () {
|
|
380
|
-
if ($('.volume').hasClass('volume-none')) {
|
|
381
|
-
// Restore previous volume state
|
|
382
|
-
$('#slider').slider( "value", prevVol );
|
|
383
|
-
currentVolumeValue = prevVol;
|
|
384
|
-
setVolume(currentVolumeValue, false);
|
|
385
|
-
$('.volume').removeClass('volume-none');
|
|
386
|
-
} else {
|
|
387
|
-
// Save previous volume state and mute audio
|
|
388
|
-
prevVol = $('#volume-range').val();
|
|
389
|
-
$('#slider').slider( "value", 0);
|
|
390
|
-
currentVolumeValue = 0;
|
|
391
|
-
setVolume(currentVolumeValue, false);
|
|
392
|
-
$('.volume').addClass('volume-none');
|
|
393
|
-
};
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
//show slider wile changing volume
|
|
398
|
-
$('.volume-range-block').focusin( function () {
|
|
399
|
-
$(this).addClass('open-width').addClass('open');
|
|
400
|
-
});
|
|
401
|
-
$('.volume-range-block').focusout( function () {
|
|
402
|
-
$(this).removeClass('open-width').removeClass('open');
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
isMobile = {
|
|
407
|
-
Android: function() {
|
|
408
|
-
return navigator.userAgent.match(/Android/i);
|
|
409
|
-
},
|
|
410
|
-
BlackBerry: function() {
|
|
411
|
-
return navigator.userAgent.match(/BlackBerry/i);
|
|
412
|
-
},
|
|
413
|
-
iOS: function() {
|
|
414
|
-
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
|
415
|
-
},
|
|
416
|
-
Opera: function() {
|
|
417
|
-
return navigator.userAgent.match(/Opera Mini/i);
|
|
418
|
-
},
|
|
419
|
-
Windows: function() {
|
|
420
|
-
return navigator.userAgent.match(/IEMobile/i);
|
|
421
|
-
},
|
|
422
|
-
any: function() {
|
|
423
|
-
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
if (isMobile.any()) {
|
|
427
|
-
$('.volume-range-block').addClass('open-width-full')
|
|
428
|
-
}
|
|
429
|
-
var prevFull;
|
|
430
|
-
|
|
431
|
-
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function(e) {
|
|
432
|
-
if (stream) {
|
|
433
|
-
|
|
434
|
-
$('.player').toggleClass('fullscreenon'); //Add class for all controls in full screen mode
|
|
435
|
-
$('.volume-range-block').toggleClass('fullscreen-vol'); //Add class to volume control for full screen mode
|
|
436
|
-
|
|
437
|
-
if ( $('.player').hasClass('fullscreenon') ) {
|
|
438
|
-
prevFull = $('.fullscreenBtn').html();
|
|
439
|
-
|
|
440
|
-
//change full screen button to full screen exit button
|
|
441
|
-
$('.fullscreenBtn').html(HTML_FULLSCREEN_EXIT);
|
|
442
|
-
|
|
443
|
-
//activate controls on mouse moving
|
|
444
|
-
$that.bind('mousemove touchmove', function () {
|
|
445
|
-
if ($clearTimeout) {
|
|
446
|
-
clearTimeout($clearTimeout);
|
|
447
|
-
}
|
|
448
|
-
$that.find('.player').stop(true, false).animate({'opacity': '1'}, 0.1);
|
|
449
|
-
$clearTimeout = setTimeout(function() {
|
|
450
|
-
$that.find('.player').stop(true, false).animate({'opacity': '0'}, 0.5);
|
|
451
|
-
}, 15000);
|
|
452
|
-
});
|
|
453
|
-
} else {
|
|
454
|
-
|
|
455
|
-
$('.fullscreenBtn').html(prevFull);
|
|
456
|
-
$('.fullscreenBtn').click(function () {
|
|
457
|
-
if ( stream ) {
|
|
458
|
-
stream.fullScreen();
|
|
459
|
-
};
|
|
460
|
-
});
|
|
461
|
-
};
|
|
462
|
-
};
|
|
463
|
-
});
|
|
464
|
-
});
|
|
319
|
+
function hideItem(id) {
|
|
320
|
+
let item = document.getElementById(id);
|
|
321
|
+
if (item) {
|
|
322
|
+
item.style.display = "none";
|
|
323
|
+
}
|
|
465
324
|
}
|
|
466
|
-
})(jQuery);
|