【问题标题】:How to change ExoPlayer subtitle position in android?如何在 android 中更改 ExoPlayer 字幕位置?
【发布时间】:2021-08-16 12:29:56
【问题描述】:

我在我的 android 应用程序中显示带有 exoPlayer 的字幕。现在我想将字幕的位置从屏幕底部更改到顶部。我尝试setBottomPaddingFractionsetPadding 到 subtitleView 但没有用。是否可以更改屏幕中的字幕位置?如果你的答案是肯定的,怎么做?

【问题讨论】:

    标签: android exoplayer subtitle


    【解决方案1】:

    我不确定这是否可行,但是您可以使用此侦听器获取 exoplayer 字幕并将其设置在您的 textView 中并将其放在您想要的任何位置:

    player.addTextOutput(new TextOutput() {
            @Override
            public void onCues(List<Cue> cues) {
    
                txtBottomSubtitle.setBackgroundColor(Color.TRANSPARENT);
                txtBottomSubtitle.setText("");
    
                if (cues.size() > 0) {
                    txtBottomSubtitle.setBackgroundColor(Color.parseColor("#80000000"));
                    htmlInTextView(txtBottomSubtitle, cues.get(0).text.toString());
                }
            }
        });
    

    【讨论】:

    • 谢谢。但是如何在那个 textView 上显示 contollerView 呢?您的回答是一个技巧,但在我的情况下不起作用。
    • 我实际上使用了我的 customControllerView。如果您没有找到答案,您必须禁用 exoplayer contollerView 并使用您的 customContollerView
    猜你喜欢
    • 1970-01-01
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 2014-09-13
    • 1970-01-01
    • 2012-03-17
    • 1970-01-01
    相关资源
    最近更新 更多