|
|
@@ -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
|