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: Can't disable subtitle on iOS when using type: disabled #1468

Closed
wants to merge 2 commits into from
Closed

Fix: Can't disable subtitle on iOS when using type: disabled #1468

wants to merge 2 commits into from

Conversation

nbennink
Copy link
Contributor

@nbennink nbennink commented Feb 6, 2019

This is a PR to fix #1144.

The original issue

When you select a textTrack it starts playing the video with subtitles. To disable these subtitle you can give the setSelectedTextTrack={{type:'disabled'}} to the Video component. This works correctly on Android, but on iOS it "freezes" the last known subtitle until the end of the video.

How does this PR fix this?

There's been a discussion about how to fix this problem. A solution was to generate an empty VTT file with a package like RNFetchBlob. I think however that it's a better solution to generate this file in the Video component itself (since that's where the issue comes from).

This PR adds an VTT file to the array of TextTracks. When the selectedTextTrack gets type: disabled it will select this track which makes the "old" track disappear.

Nothing changes in how you use texttracks. Something to note is that you can't load a completely empty VTT file. So there is a dot at the 98 hour timemark (basically never).

Edit: I only load this empty VTT file when you actually have other texttracks as well. So you don't have the issue where it breaks Airplay.

@cobarx
Copy link
Contributor

cobarx commented Mar 15, 2019

@nbennink This is a very clever and intelligent solution. I haven't had a chance to test this yet. My only concern would be whether the empty VTT track appears in the list of text tracks reported by onLoad. If so, we should filter it out.

@nbennink
Copy link
Contributor Author

nbennink commented Mar 15, 2019

@cobarx Yes you are right. My latest commit removes the subtitle file from the onLoad event. So you can't see it in your front-end and the only way to select it, is by using {type: "disabled"} (just like Android).

@danielmarino24i
Copy link
Contributor

@nbennink
Copy link
Contributor Author

nbennink commented Mar 15, 2019

I don't think that it's a problem, here in the playerItemPrepareText method the function gets returned when you don't give the video player text tracks using the textTracks prop. So the empty subtitle is not available when you don't give the player at least one text track.

This was done to prevent an issue where you can't Airplay a video that contains text tracks. I'm not using caching for my project right now, but I assume that it works the same here.

@nbennink
Copy link
Contributor Author

nbennink commented Jul 4, 2019

So I recently discovered that this is not working on tvOS. It appears that this line returns nil so it skips the empty VTT file. I think that this is limitation of the tvOS file system or AVPlayer on tvOS. I'm looking for a solution to fix it. Let me know if someone has suggestions.

@CHaNGeTe
Copy link
Contributor

CHaNGeTe commented Jul 4, 2019

@nbennink Just a quick question, are you using mp4? or adaptative streaming?
I have detected some issues with texttracks on Adaptative ones.

I was thinking in another approach for setting subtitles.

@nbennink
Copy link
Contributor Author

nbennink commented Jul 5, 2019

@CHaNGeTe I am using mp4 files for subtitles and still have this issue. I'm not sure what the best option is to replace the current approach for subtitles. I'd like to fix the problem without the empty VTT file.

Edit: I recently came back to this issue and tried again to come up with solution for tvOS but did not get it working. Anyone a suggestion?

@kotomono
Copy link

same problem here. why isnt this merged? tested and it works

@stale
Copy link

stale bot commented Apr 19, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are having a similar problem, please open a new issue and reference this one instead of commenting on a stale or closed issue.

@stale stale bot added the stale Closed due to inactivity or lack or resources label Apr 19, 2022
@hueniverse hueniverse added stale Closed due to inactivity or lack or resources and removed stale Closed due to inactivity or lack or resources labels Apr 20, 2022
@hueniverse hueniverse closed this Apr 22, 2022
ZhenhuiDev added a commit to snsdigitaldevs/react-native-video that referenced this pull request May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Closed due to inactivity or lack or resources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS Sidecar VTT TextTrack toggling does not work
6 participants