如何重新定位MediaController? [英] How to re-position the MediaController?

查看:233
本文介绍了如何重新定位MediaController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为我的应用程序使用mediaController.

I have been using mediaController for my app.

默认情况下,媒体控制器显示在屏幕底部.

By default, the Media Controller is displayed at the bottom of the screen.

是否可以在屏幕中间显示媒体控制器?

Is there a way to display the Media Controller in the middle of the screen instead?

推荐答案

仅当视频大小已知时,放置媒体控制器即可.因此,您必须这样做:

Placing the mediacontroller only works if the video size is known. Thus you'll have to do:

video.setOnPreparedListener(new OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
            mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() { 
                                    @Override
                                    public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
                                          /*
                                           *  add media controller
                                           */
                                          mc = new MediaController(YourActivity.this);;
                                          video.setMediaController(mc);
                                          /*
                                           * and set its position on screen
                                           */
                                          mc.setAnchorView(video);
                                    }
                                    });
                            }
          });

这篇关于如何重新定位MediaController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆