Skip to main content
Logo Appt Light

Captions on Android

Captions should be provided to enable users to understand what is being said in videos. Captions are a text based alternative for media, such as videos. The spoken dialogue and sound effects are displayed on screen as the video plays. Captions mostly benefit people who are deaf, hard of hearing, or deafblind. But captions are also useful to anyone who is temporarily unable to perceive sound, for example inside a library.

On Android, captions can be added by using TimedText inside a MediaPlayer. The code example below shows a basic example.

val player = MediaPlayer.create(this,
try {
    player.addTimedTextSource("/assets/", MediaPlayer.MEDIA_MIMETYPE_TEXT_SUBRIP)
    player.trackInfo.forEachIndexed { index, trackInfo ->
        if (trackInfo.trackType == TrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT) {
} catch (e: Exception) {


Let us know!