From 989091d1ed730bf4533e0447b5016e14bc1beb93 Mon Sep 17 00:00:00 2001 From: Awais Jibran Date: Wed, 10 Jun 2015 20:26:15 +0500 Subject: [PATCH] TNL-2165 "play_video" event emitted after seeking forward in a video contains old position --- .../js/spec/video/video_player_spec.js | 24 +++++++++++++++++++ .../xmodule/js/src/video/03_video_player.js | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js index 471a6589f3..843b6c3f65 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js @@ -333,6 +333,30 @@ function (VideoPlayer) { }); }); + describe('onSeek Youtube', function(){ + beforeEach(function () { + state = jasmine.initializePlayerYouTube(); + state.videoEl = $('video, iframe'); + }); + + describe('when the video is playing', function () { + beforeEach(function(){ + state.videoPlayer.onStateChange({ + data: YT.PlayerState.PLAYING + }); + }); + + it('Video has started playing', function () { + expect($('.video_control')).toHaveClass('pause'); + }); + + it('seek the player', function () { + state.videoPlayer.seekTo(10); + expect(state.videoPlayer.currentTime).toBe(10); + }); + }); + }); + describe('onSeek', function () { beforeEach(function () { state = jasmine.initializePlayer(); diff --git a/common/lib/xmodule/xmodule/js/src/video/03_video_player.js b/common/lib/xmodule/xmodule/js/src/video/03_video_player.js index 243a1730ab..0efdcd629b 100644 --- a/common/lib/xmodule/xmodule/js/src/video/03_video_player.js +++ b/common/lib/xmodule/xmodule/js/src/video/03_video_player.js @@ -493,8 +493,6 @@ function (HTML5Video, Resizer) { if (this.videoPlayer.isPlaying()) { this.videoPlayer.stopTimer(); - } else { - this.videoPlayer.currentTime = time; } var isUnplayed = this.videoPlayer.isUnstarted() || this.videoPlayer.isCued(); @@ -521,6 +519,8 @@ function (HTML5Video, Resizer) { if (this.videoPlayer.isPlaying()) { this.videoPlayer.runTimer(); } + // Update the the current time when user seek. (YoutubePlayer) + this.videoPlayer.currentTime = time; } function runTimer() {