jhomlala / betterplayer

Better video player for Flutter, with multiple configuration options. Solving typical use cases!
Apache License 2.0
919 stars 981 forks source link

Double Subtitles on iOS Device #1103

Open reykroona opened 1 year ago

reykroona commented 1 year ago

History check I've looked around on this GitHub as well as Video Player/Chewie/video_player_avfoundation. I've tried forcing to the latest versions as well. I didn't see anything that mentions this.

Describe the bug On an actual iOS device running iOS16 (I haven't been able to test it on 15 but I don't think it did this), when I use an HLS link with subtitles the subtitles automatically turn on. It looks like it's the native subtitles because if I turn on Better_Player subtitles it's then doubling up. When I check the Subtitle settings in the Accessibility Settings on the phone it's off, but if I turn it on, then off again, it works as expected. What's weird is in the simulator it seems to work correctly.

I tried this with both my code and the example code using this link and it does it on both: https://player.vimeo.com/external/761168526.m3u8?s=6b030836b44a68d9d5799c46e1485ddb79849481

To Reproduce Steps to reproduce the behavior: In the example project, change the constant hlsPlaylistUrl to https://player.vimeo.com/external/761168526.m3u8?s=6b030836b44a68d9d5799c46e1485ddb79849481 Compile and run on an actual iOS16 device. Open the page HLS Subtitles and turn on subtitles manually. You should be getting double subtitles. Turn on subtitles in System Preferences - Accessibility - Subtitles Turn off subtitles in System Preferences - Accessibility - Subtitles Force quite Example app and try again. You should only be getting the single subtitle now.

Expected behavior To only see one set of subtitles, not two.

Screenshots https://ibb.co/zSgY96f

Flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-arm, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.72.2) [✓] Connected device (3 available) [✓] HTTP Host Availability

• No issues found!

Better Player version

Smartphone (please complete the following information):

reykroona commented 1 year ago

I think I got this figured out, it seems to be only with devices that have upgraded from a previous unknown OS. Fresh installs or upgrades from iOS15 to 16 don't have this.

I added a line of code to iOS/classes/betterplayer.m on line 32: _player.appliesMediaSelectionCriteriaAutomatically = false;

You can read about it here: https://developer.apple.com/documentation/avfoundation/avplayer/1387178-appliesmediaselectioncriteriaaut

If you turn on the closed captions in the accessibility settings it doesn't display the closed captions.

I've forked the repository with the fix here: https://github.com/reykroona/betterplayer

This repository also has a merge from another issue https://github.com/jhomlala/betterplayer/issues/1093 that I was running into.

Hope this is helpful for anyone who runs into this issue.