androidandroid-videoviewvideo-subtitles

Android VideoView addSubtitleSource - Is it possible to enable it regardless of accessibility settings?


I have a VideoView that I load in subtitles programatically using addSubtitleSource.

This is all working, however they are only displayed if the user has 'Show Captions' set in the Captioning Preferences inside the system Accessibility settings.

Ideally I would like the captions to be shown regardless of their settings. Is this possible?

I know I can use TimedTextListeners with MediaPlayer, is that an alternative I should look into instead of VideoView or would that just display the same behaviour?

Or even roll out my own subtitle rendering?

(Note - For now, I'm not immediately able to support ExoPlayer, so ideally want solutions that don't use that!)


Solution

  • So looking into it further, VideoView will only ever show subtitles if the users Accessibility settings has 'Show Captions' enabled, theres no other way to get subtitles to appear. Which is annoying.

    So I've switched over to using MediaPlayer directly and using the addTimedTextListener and processing the events from that - rendering the subtitles myself in a TextView over the top.

    I have however seen a bug I'm going to post about in another question, the TimedTextListner only seems to fire events at the Start Time of a new caption, I don't get events when the caption ends (I expected to get TimedTextListener firing with a 'null' text when a caption ends).

    Here's my other question around the srt not handling end time stamps Android MediaPlayer addTimedTextSource not notifying when caption 'ends', only when a caption 'starts'