MediaController无法正常工作

时间:2017-09-01 17:48:17

标签: java android android-videoview mediacontroller

我的VideoView可以使用,但我的MediaController不起作用。我非常确定我做错了或者可能不是......

这是我的代码:



public class Main2Activity extends Activity {

    VideoView resultvideo;
    MediaController mediacontroller;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String uri = getIntent().getStringExtra("VIDEO_URI");
        Uri videoUri = Uri.parse(uri);

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main2);

        mediacontroller = new MediaController(Main2Activity.this);
        mediacontroller.setAnchorView(resultvideo);

        mediacontroller.show();
        mediacontroller.setAnchorView(resultvideo);

        resultvideo = (VideoView)findViewById(R.id.videoView2);
        resultvideo.setVideoURI(videoUri);
        resultvideo.start();

    }
}




1 个答案:

答案 0 :(得分:2)

应该使用 VideoView 设置

MediaController 以便工作。您应该调用以下内容:

resultVideo.setMediaController(mediacontroller);