Commit 4938601c by Muhammad Ammar

Merge pull request #11177 from edx/ammar/fix-play-video-event

Avoid emitting play_video event during buffering
parents 68d77011 83be42ed
(function (undefined) {
'use strict';
describe('VideoPlayer Events plugin', function () {
var state, oldOTBD;
var state, oldOTBD, Logger = window.Logger;
beforeEach(function () {
oldOTBD = window.onTouchBasedDevice;
......@@ -32,13 +32,21 @@
});
});
it('can emit "play_video" event', function () {
it('can emit "play_video" event when emitPlayVideoEvent is true', function () {
state.videoEventsPlugin.emitPlayVideoEvent = true;
state.el.trigger('play');
expect(Logger.log).toHaveBeenCalledWith('play_video', {
id: 'id',
code: 'html5',
currentTime: 10
});
expect(state.videoEventsPlugin.emitPlayVideoEvent).toBeFalsy();
});
it('can not emit "play_video" event when emitPlayVideoEvent is false', function () {
state.videoEventsPlugin.emitPlayVideoEvent = false;
state.el.trigger('play');
expect(Logger.log).not.toHaveBeenCalled();
});
it('can emit "pause_video" event', function () {
......@@ -48,6 +56,7 @@
code: 'html5',
currentTime: 10
});
expect(state.videoEventsPlugin.emitPlayVideoEvent).toBeTruthy();
});
it('can emit "speed_change_video" event', function () {
......@@ -79,6 +88,7 @@
code: 'html5',
currentTime: 10
});
expect(state.videoEventsPlugin.emitPlayVideoEvent).toBeTruthy();
Logger.log.reset();
state.el.trigger('stop');
......@@ -87,6 +97,7 @@
code: 'html5',
currentTime: 10
});
expect(state.videoEventsPlugin.emitPlayVideoEvent).toBeTruthy();
});
it('can emit "skip_video" event', function () {
......
......@@ -50,6 +50,7 @@ define('video/09_events_plugin.js', [], function() {
'destroy': this.destroy
};
this.bindHandlers();
this.emitPlayVideoEvent = true;
},
bindHandlers: function() {
......@@ -61,15 +62,20 @@ define('video/09_events_plugin.js', [], function() {
},
onPlay: function () {
this.log('play_video', {currentTime: this.getCurrentTime()});
if (this.emitPlayVideoEvent) {
this.log('play_video', {currentTime: this.getCurrentTime()});
this.emitPlayVideoEvent = false;
}
},
onPause: function () {
this.log('pause_video', {currentTime: this.getCurrentTime()});
this.emitPlayVideoEvent = true;
},
onEnded: function () {
this.log('stop_video', {currentTime: this.getCurrentTime()});
this.emitPlayVideoEvent = true;
},
onSkip: function (event, doNotShowAgain) {
......
......@@ -61,7 +61,6 @@ class VideoEventsTestMixin(EventsTestMixin, VideoBaseTest):
class VideoEventsTest(VideoEventsTestMixin):
""" Test video player event emission """
@unittest.skip('AN-5867')
def test_video_control_events(self):
"""
Scenario: Video component is rendered in the LMS in Youtube mode without HTML5 sources
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment