Search code examples
androidvimeohttp-live-streamingcaptionexoplayer

How to show HLS embedded captions on Exoplayer


how do I enable and also select different subtitles that are embedded in a Vimeo video in HLS format using Exoplayer, ExoMedia or another player? In iOS this same video already presents the option of subtitles natively but in Android I cannot find means to implement it.


Solution

  • This works well!

    TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);   
    
    TrackSelectionArray currentTrackGroups = player.getCurrentTrackSelections();
    TrackSelection currentTrackSelection = currentTrackGroups.get(rendererIndex);
    
    
        for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
    
            TrackGroup group = trackGroups.get(groupIndex);
    
            for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
                Format trackFormat = group.getFormat(trackIndex);
    
    
                if(currentTrackSelection!=null && currentTrackSelection.getSelectedFormat()==trackFormat){
                    //THIS ONE IS SELECTED
                }
    
    
    
    
            }
        }
    

    rendererIndex is 0 for Video, 1 for Audio and 2 for Subtitles/Text