Merge pull request #1337 from edx/db/fix-video-requirejs
fix video module issue with require.js
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Stub Youtube API
|
||||
window.YT =
|
||||
Player: ->
|
||||
PlayerState:
|
||||
UNSTARTED: -1
|
||||
ENDED: 0
|
||||
@@ -7,6 +8,7 @@ window.YT =
|
||||
PAUSED: 2
|
||||
BUFFERING: 3
|
||||
CUED: 5
|
||||
ready: (f) -> f()
|
||||
|
||||
window.STATUS = window.YT.PlayerState
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
afterEach(function () {
|
||||
window.OldVideoPlayer = undefined;
|
||||
window.onYouTubePlayerAPIReady = undefined;
|
||||
window.onHTML5PlayerAPIReady = undefined;
|
||||
$('source').remove();
|
||||
});
|
||||
|
||||
@@ -214,14 +212,23 @@
|
||||
// Total ajax calls made.
|
||||
numAjaxCalls = $.ajax.calls.length;
|
||||
|
||||
// Subtract ajax calls to get captions.
|
||||
// Subtract ajax calls to get captions via
|
||||
// state.videoCaption.fetchCaption() function.
|
||||
numAjaxCalls -= $.ajaxWithPrefix.calls.length;
|
||||
|
||||
// Subtract ajax calls to get metadata for each video.
|
||||
// Subtract ajax calls to get metadata for each video via
|
||||
// state.getVideoMetadata() function.
|
||||
numAjaxCalls -= 3;
|
||||
|
||||
// Subtract ajax calls to log event 'pause_video' via
|
||||
// state.videoPlayer.log() function.
|
||||
numAjaxCalls -= 3;
|
||||
|
||||
// This should leave just one call. It was made to check
|
||||
// for YT availability.
|
||||
// for YT availability. This is done in state.initialize()
|
||||
// function. SPecifically, with the statement
|
||||
//
|
||||
// this.youtubeXhr = this.getVideoMetadata();
|
||||
expect(numAjaxCalls).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
spyOn(player, 'callStateChangeCallback').andCallThrough();
|
||||
});
|
||||
|
||||
describe('click', function () {
|
||||
describe('[click]', function () {
|
||||
describe('when player is paused', function () {
|
||||
beforeEach(function () {
|
||||
spyOn(player.video, 'play').andCallThrough();
|
||||
@@ -61,7 +61,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('when player is playing', function () {
|
||||
describe('[player is playing]', function () {
|
||||
beforeEach(function () {
|
||||
spyOn(player.video, 'pause').andCallThrough();
|
||||
player.playerState = STATUS.PLAYING;
|
||||
@@ -94,7 +94,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('play', function () {
|
||||
describe('[play]', function () {
|
||||
beforeEach(function () {
|
||||
spyOn(player.video, 'play').andCallThrough();
|
||||
player.playerState = STATUS.PAUSED;
|
||||
@@ -126,7 +126,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('pause', function () {
|
||||
describe('[pause]', function () {
|
||||
beforeEach(function () {
|
||||
spyOn(player.video, 'pause').andCallThrough();
|
||||
player.playerState = STATUS.UNSTARTED;
|
||||
@@ -161,7 +161,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('canplay', function () {
|
||||
describe('[canplay]', function () {
|
||||
beforeEach(function () {
|
||||
waitsFor(function () {
|
||||
return player.getPlayerState() !== STATUS.UNSTARTED;
|
||||
@@ -193,7 +193,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('ended', function () {
|
||||
describe('[ended]', function () {
|
||||
beforeEach(function () {
|
||||
waitsFor(function () {
|
||||
return player.getPlayerState() !== STATUS.UNSTARTED;
|
||||
|
||||
@@ -83,7 +83,8 @@
|
||||
|
||||
window.YT = {
|
||||
Player: function () { },
|
||||
PlayerState: oldYT.PlayerState
|
||||
PlayerState: oldYT.PlayerState,
|
||||
ready: function(f){f();}
|
||||
};
|
||||
|
||||
spyOn(window.YT, 'Player');
|
||||
|
||||
@@ -20,17 +20,38 @@
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
var oldYT = window.YT;
|
||||
|
||||
beforeEach(function() {
|
||||
window.YT = {
|
||||
Player: function () { },
|
||||
PlayerState: oldYT.PlayerState,
|
||||
ready: function(f){f();}
|
||||
};
|
||||
|
||||
initialize();
|
||||
});
|
||||
|
||||
// Disabled when ARIA markup was added to the anchor
|
||||
xit('render the quality control', function() {
|
||||
expect(videoControl.secondaryControlsEl.html()).toContain("<a href=\"#\" class=\"quality_control\" title=\"HD\">");
|
||||
afterEach(function () {
|
||||
window.YT = oldYT;
|
||||
});
|
||||
|
||||
it('render the quality control', function() {
|
||||
expect(videoControl.secondaryControlsEl.html())
|
||||
.toContain(
|
||||
'<a ' +
|
||||
'href="#" ' +
|
||||
'class="quality_control" ' +
|
||||
'title="HD" ' +
|
||||
'role="button" ' +
|
||||
'aria-disabled="false"' +
|
||||
'>HD</a>'
|
||||
);
|
||||
});
|
||||
|
||||
it('bind the quality control', function() {
|
||||
expect($('.quality_control')).toHandleWith('click', videoQualityControl.toggleQuality);
|
||||
expect($('.quality_control'))
|
||||
.toHandleWith('click', videoQualityControl.toggleQuality);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -92,23 +92,12 @@ function (VideoPlayer) {
|
||||
// Require JS. At the time when we reach this code, the stand alone
|
||||
// HTML5 player is already loaded, so no further testing in that case
|
||||
// is required.
|
||||
var onPlayerReadyFunc;
|
||||
if (
|
||||
(
|
||||
(state.videoType === 'youtube') &&
|
||||
(window.YT) &&
|
||||
(window.YT.Player)
|
||||
) ||
|
||||
(state.videoType === 'html5')
|
||||
) {
|
||||
VideoPlayer(state);
|
||||
if(state.videoType === 'youtube') {
|
||||
YT.ready(function() {
|
||||
VideoPlayer(state);
|
||||
})
|
||||
} else {
|
||||
if (state.videoType === 'youtube') {
|
||||
onPlayerReadyFunc = 'onYouTubePlayerAPIReady';
|
||||
} else {
|
||||
onPlayerReadyFunc = 'onHTML5PlayerAPIReady';
|
||||
}
|
||||
window[onPlayerReadyFunc] = _.bind(VideoPlayer, window, state);
|
||||
VideoPlayer(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -420,7 +420,7 @@ function (HTML5Video) {
|
||||
this.videoPlayer.player.setPlaybackRate(this.speed);
|
||||
}
|
||||
|
||||
/* The following has been commented out to make sure autoplay is
|
||||
/* The following has been commented out to make sure autoplay is
|
||||
disabled for students.
|
||||
if (
|
||||
!onTouchBasedDevice() &&
|
||||
|
||||
Reference in New Issue
Block a user