Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9b3bc84

Browse files
Merge pull request openedx#1480 from edx/valera/bugfix_start_end_time_correct_navigation
Bug fix: video end time proper seek beyond.
2 parents 2628e4f + 5cd4bae commit 9b3bc84

14 files changed

+1398
-1065
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ These are notable changes in edx-platform. This is a rolling list of changes,
55
in roughly chronological order, most recent first. Add your entries at or near
66
the top. Include a label indicating the component affected.
77

8+
Blades: Video start and end times now function the same for both YouTube and
9+
HTML5 videos. If end time is set, the video can still play until the end, after
10+
it pauses on the end time.
11+
812
Blades: Disallow users to enter video url's in http.
913

1014
Blades: Fix bug when the speed can only be changed when the video is playing.
@@ -48,7 +52,7 @@ on the request instead of overwriting the POST attr
4852

4953
---------- split mongo backend refactoring changelog section ------------
5054

51-
Studio: course catalog, assets, checklists, course outline pages now use course
55+
Studio: course catalog, assets, checklists, course outline pages now use course
5256
id syntax w/ restful api style
5357

5458
Common:
@@ -57,7 +61,7 @@ Common:
5761

5862
Common: location mapper: % encode periods and dollar signs when used as key in the mapping dict
5963

60-
Common: location mapper: added a bunch of new helper functions for generating
64+
Common: location mapper: added a bunch of new helper functions for generating
6165
old location style info from a CourseLocator
6266

6367
Common: locators: allow - ~ and . in course, branch, and block ids.

common/lib/xmodule/xmodule/js/spec/video/general_spec.js

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@
9696
});
9797
});
9898

99-
it('parse the videos if subtitles do not exist', function () {
99+
it(
100+
'parse the videos if subtitles do not exist',
101+
function ()
102+
{
100103
var sub = '';
101104

102105
$('#example').find('.video').data('sub', '');
@@ -117,16 +120,41 @@
117120
ogg: null
118121
}, v = document.createElement('video');
119122

120-
if (!!(v.canPlayType && v.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/, ''))) {
121-
html5Sources['webm'] = 'xmodule/include/fixtures/test.webm';
123+
if (
124+
!!(
125+
v.canPlayType &&
126+
v.canPlayType(
127+
'video/webm; codecs="vp8, vorbis"'
128+
).replace(/no/, '')
129+
)
130+
) {
131+
html5Sources['webm'] =
132+
'xmodule/include/fixtures/test.webm';
122133
}
123134

124-
if (!!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''))) {
125-
html5Sources['mp4'] = 'xmodule/include/fixtures/test.mp4';
135+
if (
136+
!!(
137+
v.canPlayType &&
138+
v.canPlayType(
139+
'video/mp4; codecs="avc1.42E01E, ' +
140+
'mp4a.40.2"'
141+
).replace(/no/, '')
142+
)
143+
) {
144+
html5Sources['mp4'] =
145+
'xmodule/include/fixtures/test.mp4';
126146
}
127147

128-
if (!!(v.canPlayType && v.canPlayType('video/ogg; codecs="theora"').replace(/no/, ''))) {
129-
html5Sources['ogg'] = 'xmodule/include/fixtures/test.ogv';
148+
if (
149+
!!(
150+
v.canPlayType &&
151+
v.canPlayType(
152+
'video/ogg; codecs="theora"'
153+
).replace(/no/, '')
154+
)
155+
) {
156+
html5Sources['ogg'] =
157+
'xmodule/include/fixtures/test.ogv';
130158
}
131159

132160
expect(state.html5Sources).toEqual(html5Sources);
@@ -143,10 +171,10 @@
143171
});
144172
});
145173

146-
// Note that the loading of stand alone HTML5 player API is handled by
147-
// Require JS. When state.videoPlayer is created, the stand alone HTML5
148-
// player object is already loaded, so no further testing in that case
149-
// is required.
174+
// Note that the loading of stand alone HTML5 player API is
175+
// handled by Require JS. When state.videoPlayer is created,
176+
// the stand alone HTML5 player object is already loaded, so no
177+
// further testing in that case is required.
150178
describe('HTML5 API is available', function () {
151179
beforeEach(function () {
152180
state = new Video('#example');
@@ -172,8 +200,10 @@
172200

173201
describe('with speed', function () {
174202
it('return the video id for given speed', function () {
175-
expect(state.youtubeId('0.75')).toEqual(this['7tqY6eQzVhE']);
176-
expect(state.youtubeId('1.0')).toEqual(this['cogebirgzzM']);
203+
expect(state.youtubeId('0.75'))
204+
.toEqual(this['7tqY6eQzVhE']);
205+
expect(state.youtubeId('1.0'))
206+
.toEqual(this['cogebirgzzM']);
177207
});
178208
});
179209

@@ -210,7 +240,7 @@
210240
itDescription: 'start time is greater than end time',
211241
data: {start: 42, end: 24},
212242
expectData: {start: 42, end: null}
213-
},
243+
}
214244
];
215245

216246
beforeEach(function () {
@@ -234,8 +264,8 @@
234264

235265
state = new Video('#example');
236266

237-
expect(state.config.start).toBe(expectData.start);
238-
expect(state.config.end).toBe(expectData.end);
267+
expect(state.config.startTime).toBe(expectData.start);
268+
expect(state.config.endTime).toBe(expectData.end);
239269
});
240270
}
241271
});
@@ -263,7 +293,10 @@
263293
state3 = new Video('#example3');
264294
});
265295

266-
it('check for YT availability is performed only once', function () {
296+
it(
297+
'check for YT availability is performed only once',
298+
function ()
299+
{
267300
var numAjaxCalls = 0;
268301

269302
// Total ajax calls made.
@@ -307,10 +340,14 @@
307340
});
308341

309342
it('save setting for new speed', function () {
310-
expect($.cookie).toHaveBeenCalledWith('video_speed', '0.75', {
311-
expires: 3650,
312-
path: '/'
313-
});
343+
expect($.cookie).toHaveBeenCalledWith(
344+
'video_speed',
345+
'0.75',
346+
{
347+
expires: 3650,
348+
path: '/'
349+
}
350+
);
314351
});
315352
});
316353

@@ -341,10 +378,14 @@
341378
});
342379

343380
it('save setting for new speed', function () {
344-
expect($.cookie).toHaveBeenCalledWith('video_speed', '0.75', {
345-
expires: 3650,
346-
path: '/'
347-
});
381+
expect($.cookie).toHaveBeenCalledWith(
382+
'video_speed',
383+
'0.75',
384+
{
385+
expires: 3650,
386+
path: '/'
387+
}
388+
);
348389
});
349390
});
350391

common/lib/xmodule/xmodule/js/spec/video/html5_video_spec.js

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
beforeEach(function () {
1212
oldOTBD = window.onTouchBasedDevice;
13-
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
13+
window.onTouchBasedDevice = jasmine
14+
.createSpy('onTouchBasedDevice').andReturn(false);
1415
initialize();
1516
player.config.events.onReady = jasmine.createSpy('onReady');
1617
});
@@ -46,17 +47,22 @@
4647
}, 'Player state should be changed', WAIT_TIMEOUT);
4748

4849
runs(function () {
49-
expect(player.getPlayerState()).toBe(STATUS.PLAYING);
50+
expect(player.getPlayerState())
51+
.toBe(STATUS.PLAYING);
5052
});
5153
});
5254

5355
it('callback was called', function () {
5456
waitsFor(function () {
55-
return state.videoPlayer.player.getPlayerState() !== STATUS.PAUSED;
57+
var stateStatus = state.videoPlayer.player
58+
.getPlayerState();
59+
60+
return stateStatus !== STATUS.PAUSED;
5661
}, 'Player state should be changed', WAIT_TIMEOUT);
5762

5863
runs(function () {
59-
expect(player.callStateChangeCallback).toHaveBeenCalled();
64+
expect(player.callStateChangeCallback)
65+
.toHaveBeenCalled();
6066
});
6167
});
6268
});
@@ -78,7 +84,8 @@
7884
}, 'Player state should be changed', WAIT_TIMEOUT);
7985

8086
runs(function () {
81-
expect(player.getPlayerState()).toBe(STATUS.PAUSED);
87+
expect(player.getPlayerState())
88+
.toBe(STATUS.PAUSED);
8289
});
8390
});
8491

@@ -88,7 +95,8 @@
8895
}, 'Player state should be changed', WAIT_TIMEOUT);
8996

9097
runs(function () {
91-
expect(player.callStateChangeCallback).toHaveBeenCalled();
98+
expect(player.callStateChangeCallback)
99+
.toHaveBeenCalled();
92100
});
93101
});
94102
});
@@ -121,7 +129,8 @@
121129
}, 'Player state should be changed', WAIT_TIMEOUT);
122130

123131
runs(function () {
124-
expect(player.callStateChangeCallback).toHaveBeenCalled();
132+
expect(player.callStateChangeCallback)
133+
.toHaveBeenCalled();
125134
});
126135
});
127136
});
@@ -156,39 +165,26 @@
156165
return player.getPlayerState() !== STATUS.PLAYING;
157166
}, 'Player state should be changed', WAIT_TIMEOUT);
158167
runs(function () {
159-
expect(player.callStateChangeCallback).toHaveBeenCalled();
168+
expect(player.callStateChangeCallback)
169+
.toHaveBeenCalled();
160170
});
161171
});
162172
});
163173

164174
describe('[canplay]', function () {
165-
beforeEach(function () {
175+
it(
176+
'player state was changed, start/end was defined, ' +
177+
'onReady called', function ()
178+
{
166179
waitsFor(function () {
167180
return player.getPlayerState() !== STATUS.UNSTARTED;
168181
}, 'Video cannot be played', WAIT_TIMEOUT);
169-
});
170182

171-
it('player state was changed', function () {
172183
runs(function () {
173184
expect(player.getPlayerState()).toBe(STATUS.PAUSED);
174-
});
175-
});
176-
177-
it('end property was defined', function () {
178-
runs(function () {
179-
expect(player.end).not.toBeNull();
180-
});
181-
});
182-
183-
it('start position was defined', function () {
184-
runs(function () {
185-
expect(player.video.currentTime).toBe(player.start);
186-
});
187-
});
188-
189-
it('onReady callback was called', function () {
190-
runs(function () {
191-
expect(player.config.events.onReady).toHaveBeenCalled();
185+
expect(player.video.currentTime).toBe(0);
186+
expect(player.config.events.onReady)
187+
.toHaveBeenCalled();
192188
});
193189
});
194190
});
@@ -276,7 +272,8 @@
276272
it('getCurrentTime', function () {
277273
runs(function () {
278274
player.video.currentTime = 3;
279-
expect(player.getCurrentTime()).toBe(player.video.currentTime);
275+
expect(player.getCurrentTime())
276+
.toBe(player.video.currentTime);
280277
});
281278
});
282279

@@ -330,7 +327,8 @@
330327
});
331328

332329
it('getAvailablePlaybackRates', function () {
333-
expect(player.getAvailablePlaybackRates()).toEqual(playbackRates);
330+
expect(player.getAvailablePlaybackRates())
331+
.toEqual(playbackRates);
334332
});
335333
});
336334
});

common/lib/xmodule/xmodule/js/spec/video/resizer_spec.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ function (Resizer) {
66

77
describe('Resizer', function () {
88
var html = [
9-
'<div class="rszr-wrapper" style="width:200px; height: 200px;">',
10-
'<div class="rszr-el" style="width:100px; height: 150px;">',
9+
'<div ' +
10+
'class="rszr-wrapper" ' +
11+
'style="width:200px; height: 200px;"' +
12+
'>',
13+
'<div ' +
14+
'class="rszr-el" ' +
15+
'style="width:100px; height: 150px;"' +
16+
'>',
1117
'Content',
1218
'</div>',
1319
'</div>'
1420
].join(''),
15-
config, container, element;
21+
config, container, element, originalConsoleLog;
1622

1723
beforeEach(function () {
1824
setFixtures(html);
@@ -23,12 +29,17 @@ function (Resizer) {
2329
container: container,
2430
element: element
2531
};
32+
33+
originalConsoleLog = window.console.log;
34+
spyOn(console, 'log');
35+
});
36+
37+
afterEach(function () {
38+
window.console.log = originalConsoleLog;
2639
});
2740

2841
it('When Initialize without required parameters, log message is shown',
2942
function () {
30-
spyOn(console, 'log');
31-
3243
new Resizer({ });
3344
expect(console.log).toHaveBeenCalled();
3445
}

0 commit comments

Comments
 (0)