Exoplayer: MediaPlayer Controller play/pause button postion

Created on 8 Jul 2015  路  15Comments  路  Source: google/ExoPlayer

How can change play/pause button position to the center of the video surface. I have setAnchorView to the FrameLayout as in demo and in the media_controller layout, i set the layout_height for root LinearLayout to match parent and the gravity to center. Suppose to both play/pause button and seek bar to be in the middle of the video surface but didn't.

question

Most helpful comment

Could you please share your layout xml and media controller xml

All 15 comments

You should just implement your own player UI (i.e. do not use PlayerControl or MediaController).

What do you mean by do not use Playercontrol or Mediacontrol, dont derive from them? Is it not the same workflow as extending the default Android Player like here http://www.brightec.co.uk/blog/custom-android-media-controller

screen shot 2015-07-15 at 7 24 35 pm

I am using custom media controller layout.

@Schizo, @ojw28 said to do not use ORIGINAL PlayerControl/MediaController... But you can use Brightec implementation, just adapt this for Exoplayer... I do that and works perfect.

In that change MediaController for PlayerControl (Exoplayer) and this will be great, also small changes in .create()/.show() you should do for be perfect.

There is a missmatch in the datatype when setting setMediaPlayer(player.getPlayerControl)
how did you solve this? It expect a MediaPlayerControl but Exoplayers method returns a PlayerControl Object. I tried changing the custom views function to take in PlayerControl.... but at the end the layout was not showing up when playing files.

Please check my code and try that:
captura de tela 2015-07-16 as 03 35 29
captura de tela 2015-07-16 as 03 35 39

Ok Got it, I did a search Replace to replace MediaPlayercontrol with PlayerControl, but then i was replacing as well the PlayerControl interface.

Just for others what i had to do, following this tutorial; http://www.brightec.co.uk/blog/custom-android-media-controller and the help of bsyop

_1) in PlayerActivity.java_

_Change following lines_:
1) private MediaController mediaController;
2) mediaController = new MediaController(this);
3) mediaController.setAnchorView(((FrameLayout) findViewById(R.id.root)));

to

1) mediaController.setAnchorView(root);
2) mediaController = new VideoControllerView(this);
3) private VideoControllerView mediaController;

_In VideoControllView_
1) private MediaPlayerControl mPlayer;
2) public void setMediaPlayer(MediaPlayerControl player) {
3) mProgress = (ProgressBar) v.findViewById(R.id.mediacontroller_progress);

to

1) public void setMediaPlayer(PlayerControl player) {
2) private PlayerControl mPlayer;
3) mProgress = (SeekBar) v.findViewById(R.id.mediacontroller_progress);

and uncomment for the first the lines which are giving errors.

You have to:
private VideoControllerView mediaController;

And then:
captura de tela 2015-07-16 as 03 58 47

SeekEnable
Is my own variable of control, you don't need to use that.

Also the original VideoControllerView don't have Create(0), you should use show(0), i have customized that because my player are a little boring :), but that not a big deal for you.

Why do you need Create(0) This wasn't implemented in the default MediaController as well? By the way, a side effect of this new controller is, that video updates while scrubbing due to the implemented function onProgressChanged()

Well, i have customized VideoControllerView for do exactly what i need, then i make like this. Maybe you don't need.

Its ok for you now?

yeah thanks i have got to manage to make it work. thanks.

:)

Hi, i did all successfully but my mediacongtroller is showing always on top instead bottom though i put the params bottom.... Any idea why this behaviour ? Thx!!

Could you please share your layout xml and media controller xml

Was this page helpful?
0 / 5 - 0 ratings