diff --git a/src/dash-adapter.js b/src/dash-adapter.js index 9f251a57..7f9b7c0f 100644 --- a/src/dash-adapter.js +++ b/src/dash-adapter.js @@ -129,6 +129,9 @@ export default class DashAdapter extends BaseMediaSourceAdapter { if (Utils.Object.hasPropertyPath(config, 'playback.options.html5.dash')) { dashConfig = config.playback.options.html5.dash; } + if (Utils.Object.hasPropertyPath(config, 'playback.useNativeTextTrack')) { + dashConfig.textTrackVisibile = Utils.Object.getPropertyPath(config, 'playback.useNativeTextTrack'); + } return new this(videoElement, source, dashConfig); } @@ -227,7 +230,6 @@ export default class DashAdapter extends BaseMediaSourceAdapter { this._shaka = new shaka.Player(this._videoElement); this._maybeSetDrmConfig(); this._shaka.configure(this._config); - this._shaka.setTextTrackVisibility(false); this._addBindings(); } @@ -493,6 +495,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter { */ selectTextTrack(textTrack: TextTrack): void { if (this._shaka && (textTrack instanceof TextTrack) && !textTrack.active && (textTrack.kind === 'subtitles' || textTrack.kind === 'captions')) { + this._shaka.setTextTrackVisibility(this._config.textTrackVisibile); this._shaka.selectTextLanguage(textTrack.language); this._onTrackChanged(textTrack); } diff --git a/test/src/dash-adapter.spec.js b/test/src/dash-adapter.spec.js index 088304ac..c2c7e177 100644 --- a/test/src/dash-adapter.spec.js +++ b/test/src/dash-adapter.spec.js @@ -179,6 +179,8 @@ describe('DashAdapter: load', () => { dashInstance = DashAdapter.createAdapter(video, vodSource, config); dashInstance.load().then(() => { done(); + }).catch(e => { + done(e) }); }); @@ -225,6 +227,8 @@ describe('DashAdapter: destroy', () => { dashInstance._buffering.should.be.false; done(); }); + }).catch(e => { + done(e); }); }); }); @@ -307,10 +311,15 @@ describe('DashAdapter: selectVideoTrack', () => { it('should select a new video track', (done) => { let inactiveTrack; + let error; let onVideoTrackChanged = (event) => { dashInstance.removeEventListener('videotrackchanged', onVideoTrackChanged); - event.payload.selectedVideoTrack.id.should.be.equal(inactiveTrack.id); - done(); + try { + event.payload.selectedVideoTrack.id.should.be.equal(inactiveTrack.id); + done(error); + } catch (e) { + done(e); + } }; dashInstance.load().then(() => { dashInstance.addEventListener('videotrackchanged', onVideoTrackChanged); @@ -321,7 +330,11 @@ describe('DashAdapter: selectVideoTrack', () => { let activeTrack = dashInstance._getVideoTracks().filter((track) => { return track.active; })[0]; - activeTrack.id.should.be.equal(inactiveTrack.id); + try { + activeTrack.id.should.be.equal(inactiveTrack.id); + } catch (e) { + error = e; + } }); }); @@ -453,8 +466,12 @@ describe('DashAdapter: selectAudioTrack', () => { return track.active; })[0].id); setTimeout(() => { - eventIsFired.should.be.false; - done(); + try { + eventIsFired.should.be.false; + done(); + } catch (e) { + done(e); + } }, 1000) }); }); @@ -551,8 +568,12 @@ describe('DashAdapter: selectTextTrack', () => { return track.active; })[0].language); setTimeout(() => { - eventCounter.should.equals(1); - done(); + try { + eventCounter.should.equals(1); + done(); + } catch (e) { + done(e); + } }, 1000) }); }); @@ -638,12 +659,15 @@ describe('DashAdapter: enableAdaptiveBitrate', () => { TestUtils.removeVideoElementsFromTestPage(); }); - it('should enable ABR', () => { + it('should enable ABR', (done) => { dashInstance.load().then(() => { dashInstance._shaka.getConfiguration().abr.enabled.should.be.false; dashInstance.enableAdaptiveBitrate(); dashInstance._shaka.getConfiguration().abr.enabled.should.be.true; dashInstance.isAdaptiveBitrateEnabled().should.be.true; + done(); + }).catch((e) => { + done(e) }); }); @@ -651,10 +675,14 @@ describe('DashAdapter: enableAdaptiveBitrate', () => { let mode = 'manual'; let counter = 0; dashInstance.addEventListener('abrmodechanged', (event) => { - event.payload.mode.should.equal(mode); - counter++; - if (counter === 3) { - done(); + try { + event.payload.mode.should.equal(mode); + counter++; + if (counter === 3) { + done(); + } + } catch (e) { + done(e); } }); dashInstance.load().then(() => { @@ -693,6 +721,8 @@ describe('DashAdapter: isLive', () => { dashInstance.load().then(() => { dashInstance.isLive().should.be.false; done(); + }).catch(e => { + done(e); }); }); @@ -769,10 +799,12 @@ describe('DashAdapter: seekToLiveEdge', () => { dashInstance = DashAdapter.createAdapter(video, liveSource, config); dashInstance.load().then(() => { video.currentTime = dashInstance._shaka.seekRange().start; - ((dashInstance._shaka.seekRange().end - video.currentTime) >= 30).should.be.true; + ((dashInstance._shaka.seekRange().end - video.currentTime) >= 20).should.be.true; dashInstance.seekToLiveEdge(); ((dashInstance._shaka.seekRange().end - video.currentTime) <= 1).should.be.true; done(); + }).catch((e) => { + done(e) }); }); @@ -784,6 +816,8 @@ describe('DashAdapter: seekToLiveEdge', () => { dashInstance.seekToLiveEdge(); ((dashInstance._shaka.seekRange().end - video.currentTime) < 1).should.be.true; done(); + }).catch((e) => { + done(e) }); }); });