本文介绍了MediaController始终在Android上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用mediacontroller,但仅显示3秒钟.我进行了很多搜索,但是在每个文档中,我仅看到show函数,设置了超时时间,但没有任何效果.如何始终显示mediacontroller?

I am using mediacontroller in my app, but it shows only for 3 seconds. I have searched a lot, but in every document I see only the show function, set time out, but it has no effect. How can I always show mediacontroller?

我已经测试过show(0),但是没有效果.

I have tested show(0), but it had no effect.

推荐答案

您可以扩展MediaController类,并以编程方式将其实例设置为VideoView类:

You can extend the MediaController class and programmatically set an instance of it to a VideoView class:

import android.content.Context;
import android.util.AttributeSet;
import android.widget.MediaController;

public class MyMediaController extends MediaController {
    public MyMediaController(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyMediaController(Context context, boolean useFastForward) {
        super(context, useFastForward);
    }

    public MyMediaController(Context context) {
        super(context);
    }

    @Override
    public void show(int timeout) {
        super.show(0);
    }

}

用法:

VideoView myVideoView = (VideoView) findViewById(R.id.my_video_view);
MediaController mc = new MyMediaController(myVideoView.getContext());
mc.setMediaPlayer(myVideoView);
myVideoView.setMediaController(mc);

这篇关于MediaController始终在Android上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 20:07