我想使用MediaController但它不起作用?

时间:2020-10-27 23:30:28

标签: android video android-videoview mediacontroller

我希望视频播放时像停止视频时间线一样显示MediaController,但不显示这样的显示 如果我尝试了MediaController上下文的问题 getcontext和getActivity但没有用 [![在其他地方显示] [1]] [1]

@Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
            try {
              String Path = data.getData().toString();
                //Video.setVideoPath(Path);
                Uri uri = Uri.parse(Path);
                Video.setVideoURI(uri);

                MediaController mediaController = new 
                MediaController(getActivity());
                Video.setMediaController(mediaController);
                mediaController.setAnchorView(Video);
                Video.start();

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }```


  [1]: https://i.stack.imgur.com/FRrr8.png

0 个答案:

没有答案