Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Fix qualityLevels setup for video with source #979

Merged
merged 5 commits into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/videojs-contrib-hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class HlsHandler extends Component {
this.ignoreNextSeekingEvent_ = true;
});

this.setupQualityLevels_();
this.tech_.ready(() => this.setupQualityLevels_());

// do nothing if the tech has been disposed already
// this can occur if someone sets the src in player.ready(), for instance
Expand Down
15 changes: 14 additions & 1 deletion test/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,25 @@ export const mockTech = function(tech) {
};
};

export const createPlayer = function(options) {
export const createPlayer = function(options, src) {
let video;
let player;

video = document.createElement('video');
video.className = 'video-js';
if (src) {
if (typeof src === 'string') {
video.src = src;
} else if (src.src) {
let source = document.createElement('source');

source.src = src.src;
if (src.type) {
source.type = src.type;
}
video.appendChild(source);
}
}
document.querySelector('#qunit-fixture').appendChild(video);
player = videojs(video, options || {
flash: {
Expand Down
11 changes: 10 additions & 1 deletion test/videojs-contrib-hls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,7 @@ QUnit.test('populates quality levels list when available', function(assert) {
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(this.player, this.clock);

assert.ok(this.player.tech_.hls.qualityLevels_, 'added quality levels');

Expand All @@ -2365,14 +2366,22 @@ QUnit.test('populates quality levels list when available', function(assert) {
changeCount++;
});

openMediaSource(this.player, this.clock);
// master
this.standardXHRResponse(this.requests.shift());
// media
this.standardXHRResponse(this.requests.shift());

assert.equal(addCount, 4, 'four levels added from master');
assert.equal(changeCount, 1, 'selected initial quality level');

this.player.dispose();
this.player = createPlayer({}, {
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(this.player, this.clock);

assert.ok(this.player.tech_.hls.qualityLevels_, 'added quality levels from video with source');
});

QUnit.module('HLS Integration', {
Expand Down