Skip to content

Commit

Permalink
fix(FEC-7233): when parsing text tracks mark all as inactive (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv committed Oct 4, 2017
1 parent aedbb29 commit de9b1e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
for (let i = 0; i < textTracks.length; i++) {
let settings = {
kind: textTracks[i].kind ? textTracks[i].kind + 's' : "",
active: textTracks[i].active,
active: false,
label: textTracks[i].label,
language: textTracks[i].language,
index: i
Expand Down
50 changes: 25 additions & 25 deletions test/src/dash-adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('DashAdapter: _getParsedTracks', () => {
}
if (track instanceof TextTrack) {
track.kind.should.equal(textTracks[track.index].kind + 's');
track.active.should.equal(textTracks[track.index].active);
track.active.should.be.false;
track.language.should.equal(textTracks[track.index].language);
(track.label === textTracks[track.index].label).should.be.true;
}
Expand Down Expand Up @@ -524,80 +524,80 @@ describe('DashAdapter: selectTextTrack', () => {
});

it('should not change the already selected text track', (done) => {
let eventCounter = 0;
dashInstance.load().then(() => {
dashInstance.addEventListener('texttrackchanged', () => {
eventIsFired = true;
eventCounter++;
activeTrack.active = true;
});
let activeTrack = dashInstance._getParsedTextTracks().filter((track) => {
return track.active;
})[0];
let eventIsFired = false;
let activeTrack = dashInstance._getParsedTextTracks()[0];
dashInstance.selectTextTrack(activeTrack);
dashInstance.selectTextTrack(activeTrack);
activeTrack.language.should.be.equal(dashInstance._shaka.getTextTracks().filter((track) => {
return track.active;
})[0].language);
setTimeout(() => {
eventIsFired.should.be.false;
eventCounter.should.equals(1);
done();
}, 1000)
});
});

it('should not change the selected for video track given', (done) => {
let eventCounter = 0;
dashInstance.load().then(() => {
dashInstance.addEventListener('texttrackchanged', () => {
eventIsFired = true;
eventCounter++;
activeTrack.active = true;
});
let activeTrack = dashInstance._getParsedTextTracks().filter((track) => {
return track.active;
})[0];
let eventIsFired = false;
let activeTrack = dashInstance._getParsedTextTracks()[0];
dashInstance.selectTextTrack(activeTrack);
dashInstance.selectTextTrack(new VideoTrack({index: 0}));
activeTrack.language.should.be.equal(dashInstance._shaka.getTextTracks().filter((track) => {
return track.active;
})[0].language);
setTimeout(() => {
eventIsFired.should.be.false;
eventCounter.should.equals(1);
done();
}, 1000)
});
});

it('should not change the selected for no text track given', (done) => {
let eventCounter = 0;
dashInstance.load().then(() => {
dashInstance.addEventListener('texttrackchanged', () => {
eventIsFired = true;
eventCounter++;
activeTrack.active = true;
});
let activeTrack = dashInstance._getParsedTextTracks().filter((track) => {
return track.active;
})[0];
let eventIsFired = false;
let activeTrack = dashInstance._getParsedTextTracks()[0];
dashInstance.selectTextTrack(activeTrack);
dashInstance.selectTextTrack();
activeTrack.language.should.be.equal(dashInstance._shaka.getTextTracks().filter((track) => {
return track.active;
})[0].language);
setTimeout(() => {
eventIsFired.should.be.false;
eventCounter.should.equals(1);
done();
}, 1000)
});
});

it('should not change the selected for no subtitle or captions given', (done) => {
let eventCounter = 0;
dashInstance.load().then(() => {
dashInstance.addEventListener('texttrackchanged', () => {
eventIsFired = true;
eventCounter++;
activeTrack.active = true;
});
let activeTrack = dashInstance._getParsedTextTracks().filter((track) => {
return track.active;
})[0];
let eventIsFired = false;
let activeTrack = dashInstance._getParsedTextTracks()[0];
dashInstance.selectTextTrack(activeTrack);
dashInstance.selectTextTrack(new TextTrack({kind: 'metadata'}));
activeTrack.language.should.be.equal(dashInstance._shaka.getTextTracks().filter((track) => {
return track.active;
})[0].language);
setTimeout(() => {
eventIsFired.should.be.false;
eventCounter.should.equals(1);
done();
}, 1000)
});
Expand Down

0 comments on commit de9b1e5

Please sign in to comment.