Skip to content
Open
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
15 changes: 9 additions & 6 deletions src/playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,22 @@ export class PlaylistController extends videojs.EventTarget {
// setup segment loaders
// combined audio/video or just video when alternate audio track is selected
this.mainSegmentLoader_ =
new SegmentLoader(merge(segmentLoaderSettings, {
new SegmentLoader({
...segmentLoaderSettings,
segmentMetadataTrack: this.segmentMetadataTrack_,
loaderType: 'main'
}), options);
}, options);

// alternate audio track
this.audioSegmentLoader_ =
new SegmentLoader(merge(segmentLoaderSettings, {
new SegmentLoader({
...segmentLoaderSettings,
loaderType: 'audio'
}), options);
}, options);

this.subtitleSegmentLoader_ =
new VTTSegmentLoader(merge(segmentLoaderSettings, {
new VTTSegmentLoader({
...segmentLoaderSettings,
loaderType: 'vtt',
featuresNativeTextTracks: this.tech_.featuresNativeTextTracks,
loadVttJs: () => new Promise((resolve, reject) => {
Expand All @@ -330,7 +333,7 @@ export class PlaylistController extends videojs.EventTarget {
// safe to call multiple times, script will be loaded only once:
tech.addWebVttScript_();
})
}), options);
}, options);

const getBandwidth = () => {
return this.mainSegmentLoader_.bandwidth;
Expand Down
21 changes: 21 additions & 0 deletions test/playlist-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@ const sharedHooks = {

QUnit.module('PlaylistController', sharedHooks);

QUnit.test('segment removal clears inband metadata cues created by the controller', function(assert) {
const controller = this.playlistController;
const loader = controller.mainSegmentLoader_;
const cue = {startTime: 2, endTime: 3};
const track = {
cues: [cue],
removeCue(removedCue) {
this.cues.splice(this.cues.indexOf(removedCue), 1);
}
};

controller.inbandTextTracks_.metadataTrack_ = track;
sinon.stub(loader, 'getMediaInfo_').returns({});
sinon.stub(loader.sourceUpdater_, 'removeAudio').callsFake((start, end, done) => done());
sinon.stub(loader.sourceUpdater_, 'removeVideo').callsFake((start, end, done) => done());

loader.remove(0, 4);

assert.strictEqual(track.cues.length, 0, 'evicted metadata cue is removed');
});

QUnit.test('getAudioTrackPlaylists_ works', function(assert) {
const pc = this.playlistController;
const mainPlaylist = {playlists: [{uri: 'testing'}]};
Expand Down