Skip to content

Commit

Permalink
track fallback: attempt to match group-ids of current level and fallb…
Browse files Browse the repository at this point in the history
…ack-track
  • Loading branch information
tchakabam committed May 15, 2018
1 parent 690ba79 commit 859c5a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/controller/audio-track-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import { ErrorTypes, ErrorDetails } from '../errors';
*/
class AudioTrackController extends TaskLoop {
constructor (hls) {
super(hls, Event.MANIFEST_LOADING,
super(hls,
Event.MANIFEST_LOADING,
Event.MANIFEST_PARSED,
Event.AUDIO_TRACK_LOADED,
Event.ERROR);
Event.LEVEL_LOADED,
Event.ERROR
);

/**
* @member {AudioTrack[]}
Expand Down Expand Up @@ -94,6 +97,10 @@ class AudioTrackController extends TaskLoop {
}
}

onLevelLoaded (data) {
console.log('level loaded:', data);
}

/**
* @type {AudioTrack[]} Audio-track list
*/
Expand Down Expand Up @@ -199,13 +206,19 @@ class AudioTrackController extends TaskLoop {

// Let's try to fall back on a functional audio-track with the same group ID
const previousId = this.trackId;
const { groupId } = this.tracks[previousId];
const { groupId, name, language } = this.tracks[previousId];

logger.warn('Loading failed on audio track id:', previousId, 'group id:', groupId);

console.log(this.hls.currentLevel.details);

// Find a non-blacklisted track ID with the same group ID
let newId = this.trackId;
while (this.trackIdBlacklist[newId] && this.tracks[newId].groupId === groupId) {
while (this.trackIdBlacklist[newId] &&
this.tracks[newId].groupId !== groupId &&
this.tracks[newId].language === language &&
this.tracks[newId].name === name
) {
newId++;
if (newId >= this.tracks.length) {
newId = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/loader/m3u8-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export default class M3U8Parser {
while ((result = MASTER_PLAYLIST_REGEX.exec(string)) != null) {
const level = {};

let attrs = level.attrs = new AttrList(result[1]);
const attrs = level.attrs = new AttrList(result[1]);
level.url = M3U8Parser.resolve(result[2], baseurl);

let resolution = attrs.decimalResolution('RESOLUTION');
const resolution = attrs.decimalResolution('RESOLUTION');
if (resolution) {
level.width = resolution.width;
level.height = resolution.height;
Expand Down

0 comments on commit 859c5a6

Please sign in to comment.