Commit 8956b403 by Awais Jibran

'pause_video' event should emit in addition to the 'stop_video' when user…

'pause_video' event should emit in addition to the 'stop_video' when user watches the video completely (For Youtube videos)

TNL-2167
parent 46cb847e
......@@ -196,6 +196,29 @@ function (VideoPlayer) {
});
});
describe('onStateChange Youtube', function(){
describe('when the video is ended', function () {
beforeEach(function () {
state = jasmine.initializePlayerYouTube();
state.videoEl = $('video, iframe');
spyOn($.fn, 'trigger').andCallThrough();
state.videoPlayer.onStateChange({
data: YT.PlayerState.ENDED
});
});
it('pause the video control', function () {
expect($('.video_control')).toHaveClass('play');
});
it('trigger pause and ended events', function () {
expect($.fn.trigger).toHaveBeenCalledWith('pause', {});
expect($.fn.trigger).toHaveBeenCalledWith('ended', {});
});
});
});
describe('onStateChange', function () {
describe('when the video is unstarted', function () {
beforeEach(function () {
......
......@@ -553,6 +553,11 @@ function (HTML5Video, Resizer) {
// `duration`. In this case, slider doesn't reach the end point of
// timeline.
this.videoPlayer.updatePlayTime(time);
// Emit 'pause_video' event when a video ends if Player is of Youtube
if (this.isYoutubeType()) {
this.el.trigger('pause', arguments);
}
this.el.trigger('ended', arguments);
}
......
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