Fixed many issues with subtitle handling #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Most of the subtitle handling was being inherited from HTML5Video playback which is fundamentally incompatible with the way hls.js wants to do things. It caused many issues. This pull request fixes all the issues I found.
clappr/clappr#2003
Changes
Overrode several properties from the HTML5Video playback with hlsjs-specific implementations. The fixes are rather extensive; like I said, the existing subtitle implementation was fundamentally incompatible with hls.js. All issues I reported here are resolved by this pull request.
DEFAULT=YES
attribute was added to one of the subtitle tracks in the HLS manifest. The problem was, hlsjs-playback was not listening to the right hls.js events, and therefore was unaware that subtitles were available unless hls.js automatically activated a subtitle track.cc-button
GUI state and actual hls.js subtitle controller state. (see related PR in clappr-plugins)EXT-X-MEDIA
tag attributesDEFAULT
,AUTOSELECT
, andFORCED
. hls.js had some primitive handling ofDEFAULT
but this implementation is better, and effectively overrides hls.js default behavior.attributes
field to text tracks exposed via the playback'sclosedCaptionsTracks
property.{ autoselect: true, default: true, forced: false }
How to test
I've created a sample HLS video which can be used to test HLS playback with two subtitle languages.
TestPattern-min.zip
When extracted into the clappr repo's
public
folder, it can be loaded on the test page (npm run start
) by entering the relative URL toindex.m3u8
.Prior to the changes in this pull request, there are many issues with the subtitle handling as described in the issue I posted last week. After applying this pull request, the issues are resolved and subtitles work as intended.