|
|
@@ -44,7 +44,8 @@ export default class SharedVideoManager {
|
|
44
|
44
|
|
|
45
|
45
|
if(APP.conference.isLocalId(this.from)) {
|
|
46
|
46
|
showStopVideoPropmpt().then(() =>
|
|
47
|
|
- this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO, null, 'stop'));
|
|
|
47
|
+ this.emitter.emit(
|
|
|
48
|
+ UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
|
|
48
|
49
|
} else {
|
|
49
|
50
|
messageHandler.openMessageDialog(
|
|
50
|
51
|
"dialog.shareVideoTitle",
|
|
|
@@ -64,6 +65,8 @@ export default class SharedVideoManager {
|
|
64
|
65
|
if (this.isSharedVideoShown)
|
|
65
|
66
|
return;
|
|
66
|
67
|
|
|
|
68
|
+ this.isSharedVideoShown = true;
|
|
|
69
|
+
|
|
67
|
70
|
// the video url
|
|
68
|
71
|
this.url = url;
|
|
69
|
72
|
|
|
|
@@ -82,7 +85,7 @@ export default class SharedVideoManager {
|
|
82
|
85
|
// we need to operate with player after start playing
|
|
83
|
86
|
// self.player will be defined once it start playing
|
|
84
|
87
|
// and will process any initial attributes if any
|
|
85
|
|
- this.initialAttributes = null;
|
|
|
88
|
+ this.initialAttributes = attributes;
|
|
86
|
89
|
|
|
87
|
90
|
var self = this;
|
|
88
|
91
|
if(self.isPlayerAPILoaded)
|
|
|
@@ -148,8 +151,6 @@ export default class SharedVideoManager {
|
|
148
|
151
|
SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo);
|
|
149
|
152
|
VideoLayout.handleVideoThumbClicked(self.url);
|
|
150
|
153
|
|
|
151
|
|
- self.isSharedVideoShown = true;
|
|
152
|
|
-
|
|
153
|
154
|
// If we are sending the command and we are starting the player
|
|
154
|
155
|
// we need to continuously send the player current time position
|
|
155
|
156
|
if(APP.conference.isLocalId(self.from)) {
|
|
|
@@ -157,17 +158,12 @@ export default class SharedVideoManager {
|
|
157
|
158
|
self.updateCheck.bind(self),
|
|
158
|
159
|
updateInterval);
|
|
159
|
160
|
}
|
|
160
|
|
-
|
|
161
|
|
- if(self.player)
|
|
162
|
|
- self.processAttributes(
|
|
163
|
|
- self.player, attributes, self.playerPaused);
|
|
164
|
|
- else {
|
|
165
|
|
- self.initialAttributes = attributes;
|
|
166
|
|
- }
|
|
167
|
161
|
};
|
|
168
|
162
|
|
|
169
|
163
|
window.onPlayerError = function(event) {
|
|
170
|
|
- console.error("Error in the player:" + event.data);
|
|
|
164
|
+ console.error("Error in the player:", event.data);
|
|
|
165
|
+ // store the error player, so we can remove it
|
|
|
166
|
+ self.errorInPlayer = event.target;
|
|
171
|
167
|
};
|
|
172
|
168
|
}
|
|
173
|
169
|
|
|
|
@@ -184,7 +180,7 @@ export default class SharedVideoManager {
|
|
184
|
180
|
|
|
185
|
181
|
if (attributes.state == 'playing') {
|
|
186
|
182
|
|
|
187
|
|
- this.processTime(player, attributes);
|
|
|
183
|
+ this.processTime(player, attributes, playerPaused);
|
|
188
|
184
|
|
|
189
|
185
|
// lets check the volume
|
|
190
|
186
|
if (attributes.volume !== undefined &&
|
|
|
@@ -200,7 +196,9 @@ export default class SharedVideoManager {
|
|
200
|
196
|
// if its not paused, pause it
|
|
201
|
197
|
player.pauseVideo();
|
|
202
|
198
|
|
|
203
|
|
- this.processTime(player, attributes);
|
|
|
199
|
+ this.processTime(player, attributes, !playerPaused);
|
|
|
200
|
+ } else if (attributes.state == 'stop') {
|
|
|
201
|
+ this.stopSharedVideo(this.from);
|
|
204
|
202
|
}
|
|
205
|
203
|
}
|
|
206
|
204
|
|
|
|
@@ -208,9 +206,15 @@ export default class SharedVideoManager {
|
|
208
|
206
|
* Check for time in attributes and if needed seek in current player
|
|
209
|
207
|
* @param player the player to operate over
|
|
210
|
208
|
* @param attributes the attributes with the player state we want
|
|
|
209
|
+ * @param forceSeek whether seek should be forced
|
|
211
|
210
|
*/
|
|
212
|
|
- processTime (player, attributes)
|
|
|
211
|
+ processTime (player, attributes, forceSeek)
|
|
213
|
212
|
{
|
|
|
213
|
+ if(forceSeek) {
|
|
|
214
|
+ player.seekTo(attributes.time);
|
|
|
215
|
+ return;
|
|
|
216
|
+ }
|
|
|
217
|
+
|
|
214
|
218
|
// check received time and current time
|
|
215
|
219
|
let currentPosition = player.getCurrentTime();
|
|
216
|
220
|
let diff = Math.abs(attributes.time - currentPosition);
|
|
|
@@ -230,8 +234,10 @@ export default class SharedVideoManager {
|
|
230
|
234
|
updateCheck(sendPauseEvent)
|
|
231
|
235
|
{
|
|
232
|
236
|
// ignore update checks if we are not the owner of the video
|
|
233
|
|
- // or there is still no player defined
|
|
234
|
|
- if(!APP.conference.isLocalId(this.from) || !this.player)
|
|
|
237
|
+ // or there is still no player defined or we are stopped
|
|
|
238
|
+ // (in a process of stopping)
|
|
|
239
|
+ if(!APP.conference.isLocalId(this.from) || !this.player
|
|
|
240
|
+ || !this.isSharedVideoShown)
|
|
235
|
241
|
return;
|
|
236
|
242
|
|
|
237
|
243
|
let state = this.player.getPlayerState();
|
|
|
@@ -281,13 +287,22 @@ export default class SharedVideoManager {
|
|
281
|
287
|
* left and we want to remove video if the user sharing it left).
|
|
282
|
288
|
* @param id the id of the sender of the command
|
|
283
|
289
|
*/
|
|
284
|
|
- stopSharedVideo (id) {
|
|
|
290
|
+ stopSharedVideo (id, attributes) {
|
|
285
|
291
|
if (!this.isSharedVideoShown)
|
|
286
|
292
|
return;
|
|
287
|
293
|
|
|
288
|
294
|
if(this.from !== id)
|
|
289
|
295
|
return;
|
|
290
|
296
|
|
|
|
297
|
+ if(!this.player){
|
|
|
298
|
+ // if there is no error in the player till now,
|
|
|
299
|
+ // store the initial attributes
|
|
|
300
|
+ if (!this.errorInPlayer) {
|
|
|
301
|
+ this.initialAttributes = attributes;
|
|
|
302
|
+ return;
|
|
|
303
|
+ }
|
|
|
304
|
+ }
|
|
|
305
|
+
|
|
291
|
306
|
if(this.intervalId) {
|
|
292
|
307
|
clearInterval(this.intervalId);
|
|
293
|
308
|
this.intervalId = null;
|
|
|
@@ -300,12 +315,19 @@ export default class SharedVideoManager {
|
|
300
|
315
|
VideoLayout.removeLargeVideoContainer(
|
|
301
|
316
|
SHARED_VIDEO_CONTAINER_TYPE);
|
|
302
|
317
|
|
|
303
|
|
- this.player.destroy();
|
|
304
|
|
- this.player = null;
|
|
|
318
|
+ if(this.player) {
|
|
|
319
|
+ this.player.destroy();
|
|
|
320
|
+ this.player = null;
|
|
|
321
|
+ }//
|
|
|
322
|
+ else if (this.errorInPlayer) {
|
|
|
323
|
+ this.errorInPlayer.destroy();
|
|
|
324
|
+ this.errorInPlayer = null;
|
|
|
325
|
+ }
|
|
305
|
326
|
});
|
|
306
|
327
|
|
|
307
|
328
|
this.url = null;
|
|
308
|
329
|
this.isSharedVideoShown = false;
|
|
|
330
|
+ this.initialAttributes = null;
|
|
309
|
331
|
}
|
|
310
|
332
|
}
|
|
311
|
333
|
|