Browse Source

Make sure we store initial attributes in order, so it will hold the last state we want to be in. Respects quick initial stop received.

j8
damencho 9 years ago
parent
commit
104503ee13
3 changed files with 17 additions and 14 deletions
  1. 1
    1
      conference.js
  2. 1
    1
      modules/UI/UI.js
  3. 15
    12
      modules/UI/shared_video/SharedVideo.js

+ 1
- 1
conference.js View File

@@ -1110,7 +1110,7 @@ export default {
1110 1110
             Commands.SHARED_VIDEO, ({value, attributes}, id) => {
1111 1111
 
1112 1112
                 if (attributes.state === 'stop') {
1113
-                    APP.UI.stopSharedVideo(id);
1113
+                    APP.UI.stopSharedVideo(id, attributes);
1114 1114
                 } else if (attributes.state === 'start') {
1115 1115
                     APP.UI.showSharedVideo(id, value, attributes);
1116 1116
                 } else if (attributes.state === 'playing'

+ 1
- 1
modules/UI/UI.js View File

@@ -1115,7 +1115,7 @@ UI.updateSharedVideo = function (id, url, attributes) {
1115 1115
  */
1116 1116
 UI.stopSharedVideo = function (id, attributes) {
1117 1117
     if (sharedVideoManager)
1118
-        sharedVideoManager.stopSharedVideo(id);
1118
+        sharedVideoManager.stopSharedVideo(id, attributes);
1119 1119
 };
1120 1120
 
1121 1121
 module.exports = UI;

+ 15
- 12
modules/UI/shared_video/SharedVideo.js View File

@@ -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",
@@ -84,7 +85,7 @@ export default class SharedVideoManager {
84 85
         // we need to operate with player after start playing
85 86
         // self.player will be defined once it start playing
86 87
         // and will process any initial attributes if any
87
-        this.initialAttributes = null;
88
+        this.initialAttributes = attributes;
88 89
 
89 90
         var self = this;
90 91
         if(self.isPlayerAPILoaded)
@@ -157,13 +158,6 @@ 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) {
@@ -201,6 +195,8 @@ export default class SharedVideoManager {
201 195
             player.pauseVideo();
202 196
 
203 197
             this.processTime(player, attributes, !playerPaused);
198
+        } else if (attributes.state == 'stop') {
199
+            this.stopSharedVideo(this.from);
204 200
         }
205 201
     }
206 202
 
@@ -236,8 +232,10 @@ export default class SharedVideoManager {
236 232
     updateCheck(sendPauseEvent)
237 233
     {
238 234
         // ignore update checks if we are not the owner of the video
239
-        // or there is still no player defined
240
-        if(!APP.conference.isLocalId(this.from) || !this.player)
235
+        // or there is still no player defined or we are stopped
236
+        // (in a process of stopping)
237
+        if(!APP.conference.isLocalId(this.from) || !this.player
238
+            || !this.isSharedVideoShown)
241 239
             return;
242 240
 
243 241
         let state = this.player.getPlayerState();
@@ -287,13 +285,18 @@ export default class SharedVideoManager {
287 285
      * left and we want to remove video if the user sharing it left).
288 286
      * @param id the id of the sender of the command
289 287
      */
290
-    stopSharedVideo (id) {
288
+    stopSharedVideo (id, attributes) {
291 289
         if (!this.isSharedVideoShown)
292 290
             return;
293 291
 
294 292
         if(this.from !== id)
295 293
             return;
296 294
 
295
+        if(!this.player){
296
+            this.initialAttributes = attributes;
297
+            return;
298
+        }
299
+
297 300
         if(this.intervalId) {
298 301
             clearInterval(this.intervalId);
299 302
             this.intervalId = null;

Loading…
Cancel
Save