Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-7233): when parsing text tracks mark all as inactive #30

Merged
merged 2 commits into from
Oct 4, 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/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