-
Notifications
You must be signed in to change notification settings - Fork 7
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-7935): fix text selection logic with hlsjs #65
Changes from all commits
2c43373
4411be8
a9a29b8
0b1e27b
005ee0d
a3cfcf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,9 @@ export default class HlsAdapter extends BaseMediaSourceAdapter { | |
adapterConfig.hlsConfig.startPosition = config.playback.startTime; | ||
} | ||
} | ||
if (Utils.Object.hasPropertyPath(config, 'playback.useNativeTextTrack')) { | ||
adapterConfig.subtitleDisplay = Utils.Object.getPropertyPath(config, 'playback.useNativeTextTrack'); | ||
} | ||
return new this(videoElement, source, adapterConfig); | ||
} | ||
|
||
|
@@ -202,6 +205,7 @@ export default class HlsAdapter extends BaseMediaSourceAdapter { | |
this._config.hlsConfig['pLoader'] = pLoader; | ||
} | ||
this._hls = new Hlsjs(this._config.hlsConfig); | ||
this._hls.subtitleDisplay = this._config.subtitleDisplay; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary. see the comment above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my comment above |
||
this._addBindings(); | ||
} | ||
|
||
|
@@ -479,8 +483,7 @@ export default class HlsAdapter extends BaseMediaSourceAdapter { | |
*/ | ||
selectTextTrack(textTrack: TextTrack): void { | ||
if (textTrack instanceof TextTrack && !textTrack.active && this._videoElement.textTracks) { | ||
this._disableAllTextTracks(); | ||
this._videoElement.textTracks[textTrack.index].mode = 'hidden'; | ||
this._hls.subtitleTrack = textTrack.index; | ||
HlsAdapter._logger.debug('Text track changed', textTrack); | ||
this._onTrackChanged(textTrack); | ||
} | ||
|
@@ -492,7 +495,7 @@ export default class HlsAdapter extends BaseMediaSourceAdapter { | |
* @public | ||
*/ | ||
hideTextTrack(): void { | ||
this._disableAllTextTracks(); | ||
this._hls.subtitleTrack = -1; | ||
} | ||
|
||
/** | ||
|
@@ -644,18 +647,6 @@ export default class HlsAdapter extends BaseMediaSourceAdapter { | |
} | ||
} | ||
|
||
/** | ||
* Disables all the video tag text tracks. | ||
* @returns {void} | ||
* @private | ||
*/ | ||
_disableAllTextTracks() { | ||
let vidTextTracks = this._videoElement.textTracks; | ||
for (let i = 0; i < vidTextTracks.length; i++) { | ||
vidTextTracks[i].mode = 'disabled'; | ||
} | ||
} | ||
|
||
/** | ||
* Handles hls errors. | ||
* @param {any} data - The event data object. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,29 +210,6 @@ describe('HlsAdapter Instance - Unit', function () { | |
JSON.parse(JSON.stringify(tracks)).should.deep.equal(allTracks); | ||
}); | ||
|
||
it('should disable all text tracks', function () { | ||
hlsAdapterInstance._videoElement = { | ||
textTracks: hls_tracks.subtitles, | ||
removeEventListener: () => {} | ||
}; | ||
hlsAdapterInstance._disableAllTextTracks(); | ||
for (let i = 0; i < hlsAdapterInstance._videoElement.textTracks.length; i++) { | ||
hlsAdapterInstance._videoElement.textTracks[i].mode.should.equal('disabled'); | ||
} | ||
}); | ||
|
||
it('should hide the active text track', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why to remove this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we managed the tracks directly ourselves - so it made sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we just checking that our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand but the test doesn't reflect it - in our unit testing we inject the text tracks ourselves and not via hlsjs so we actually don't test correctly. |
||
hlsAdapterInstance._videoElement = { | ||
textTracks: hls_tracks.subtitles, | ||
removeEventListener: () => {} | ||
}; | ||
hlsAdapterInstance._videoElement.textTracks[0].mode = 'showing'; | ||
hlsAdapterInstance.hideTextTrack(); | ||
for (let i = 0; i < hlsAdapterInstance._videoElement.textTracks.length; i++) { | ||
hlsAdapterInstance._videoElement.textTracks[i].mode.should.equal('disabled'); | ||
} | ||
}); | ||
|
||
it('should enable adaptive bitrate', function () { | ||
hlsAdapterInstance._hls = { | ||
on: function () { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add it on
adapterConfig.hlsConfig
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not an hls.js config option - it's an API. I wanted to add it as config first but it doesn't get set on hls.js config...