Search code examples
javaandroidmediacontroller

Android MediaController isn't showing after call to show(0)


Here is my custom MediaController class... just to get rid of the method that hides the controller after 3 seconds.

MusicController.java

import android.content.Context;
import android.widget.MediaController;    
public class MusicController extends MediaController {

    public MusicController(Context c) {
        super(c);
    }

    public void hide() {

    }
}

I implement android.widget.MediaController.MediaPlayerControl in my MainActivity class.

public class MainActivity extends AppCompatActivity implements MediaPlayerControl

I create a MusicController and call the .show() method

    controller.show(0);

Yet... it still doesn't show on my app. Could someone explain to me the reasons this could be? Is there anything I should double check?

It gives me this when I click on one of my songs.

E/MediaPlayer: mOnVideoSizeChangedListener is null. Failed to send MEDIA_SET_VIDEO_SIZE message.

I don't understand... it's not a video. Why does it think it's a video?

I checked by calling System.out.println(controller.isShowing()) and it printed out false.


Solution

  • Alright guys... I found out why it wasn't working :P

    I didn't setAnchorView for my MediaController correctly. I set it to my relative layout and it works like a charm. :)