Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-position the 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?

like image 535
Andro Selva Avatar asked May 23 '11 06:05

Andro Selva


1 Answers

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);
                                    }
                                    });
                            }
          });
like image 194
bk138 Avatar answered Nov 25 '22 15:11

bk138