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