Browse Source

Merge pull request #560 from damencho/seek-on-start-paused

Seeks in video when we start in paused state.
master
yanas 9 years ago
parent
commit
0bde7de37b
2 changed files with 25 additions and 12 deletions
  1. 1
    0
      conference.js
  2. 24
    12
      modules/UI/shared_video/SharedVideo.js

+ 1
- 0
conference.js View File

@@ -1101,6 +1101,7 @@ export default {
1101 1101
             else {
1102 1102
                 // in case of paused, in order to allow late users to join
1103 1103
                 // paused
1104
+                room.removeCommand(Commands.SHARED_VIDEO);
1104 1105
                 room.sendCommand(Commands.SHARED_VIDEO, {
1105 1106
                     value: url,
1106 1107
                     attributes: {

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

@@ -184,17 +184,7 @@ export default class SharedVideoManager {
184 184
 
185 185
         if (attributes.state == 'playing') {
186 186
 
187
-            // check received time and current time
188
-            let currentPosition = player.getCurrentTime();
189
-            let diff = Math.abs(attributes.time - currentPosition);
190
-
191
-            // if we drift more than the interval for checking
192
-            // sync, the interval is in milliseconds
193
-            if(diff > updateInterval/1000) {
194
-                console.info("DDD Player seekTo:", attributes.time,
195
-                    " current time is:", currentPosition, " diff:", diff);
196
-                player.seekTo(attributes.time);
197
-            }
187
+            this.processTime(player, attributes);
198 188
 
199 189
             // lets check the volume
200 190
             if (attributes.volume !== undefined &&
@@ -209,6 +199,28 @@ export default class SharedVideoManager {
209 199
         } else if (attributes.state == 'pause') {
210 200
             // if its not paused, pause it
211 201
             player.pauseVideo();
202
+
203
+            this.processTime(player, attributes);
204
+        }
205
+    }
206
+
207
+    /**
208
+     * Check for time in attributes and if needed seek in current player
209
+     * @param player the player to operate over
210
+     * @param attributes the attributes with the player state we want
211
+     */
212
+    processTime (player, attributes)
213
+    {
214
+        // check received time and current time
215
+        let currentPosition = player.getCurrentTime();
216
+        let diff = Math.abs(attributes.time - currentPosition);
217
+
218
+        // if we drift more than the interval for checking
219
+        // sync, the interval is in milliseconds
220
+        if(diff > updateInterval/1000) {
221
+            console.info("Player seekTo:", attributes.time,
222
+                " current time is:", currentPosition, " diff:", diff);
223
+            player.seekTo(attributes.time);
212 224
         }
213 225
     }
214 226
 
@@ -226,7 +238,7 @@ export default class SharedVideoManager {
226 238
         // if its paused and haven't been pause - send paused
227 239
         if (state === YT.PlayerState.PAUSED && sendPauseEvent) {
228 240
             this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO,
229
-                this.url, 'pause');
241
+                this.url, 'pause', this.player.getCurrentTime());
230 242
         }
231 243
         // if its playing and it was paused - send update with time
232 244
         // if its playing and was playing just send update with time

Loading…
Cancel
Save