首页 > 解决方案 > 视图仅出现在顶部或根本不出现

问题描述

我有具有三个视图的 AspectRationFrameLayout(按此顺序):

  1. Exoplayer 视图(带视频查看)
  2. Cordova 视图(玩家的 UI)
  3. 字幕视图

我需要字幕高于“1.Exoplayer 视图”,但低于“2.Cordova 视图”以查看播放器的 UI。问题是当我将字幕视图放在“2.Cordova 视图”下方时,字幕消失并且不再显示。

问题本身是:发生这种情况的可能原因是什么?我可以检查什么?

Cordova 视图是透明的,您可以通过它看到视频,但不能看到字幕。字幕仅在位于 Cordova 视图顶部时显示。

请检查下面的截图:

顶部的字幕视图

标签: androidandroid-layoutexoplayerexoplayer2.x

解决方案


嗨,无需添加字幕视图 exoplayer 带有字幕功能,您可以像这样使用它

MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"),
            mediaDataSourceFactory, extractorsFactory, null, null);
    Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,
            null, Format.NO_VALUE, Format.NO_VALUE, "en", null);
    Uri uri = Uri.parse("http://www.storiesinflight.com/js_videosub/jellies.srt");
    MediaSource subtitleSource = new SingleSampleMediaSource(uri, mediaDataSourceFactory, textFormat, C.TIME_UNSET);

    MergingMediaSource mergedSource = new MergingMediaSource(mediaSource, subtitleSource);

    player.prepare(mergedSource);

有关更多详细信息,请查看本教程,您也可以查看错误提示


推荐阅读