本文介绍了如何在Exoplayer上显示HLS嵌入式字幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Exoplayer,ExoMedia或其他播放器启用HLS格式的Vimeo视频中嵌入的字幕,以及如何选择这些字幕?在iOS中,该视频已经在本地提供了字幕选项,但是在Android中,我找不到实现该字幕的方法.

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.

推荐答案

这很好!

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对于视频是0,对于音频是1,对于字幕/文本是2

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

这篇关于如何在Exoplayer上显示HLS嵌入式字幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 12:17