Determining when the android MediaController view becomes visible

122 views Asked by At

I'm using the MediaController class to anchor the video controller views to my VideoView. When the VideoView is clicked,the controller becomes visible for some few seconds then leaves the screen. Is there a listener in the MediaController that allows us know the moment it becomes visible or not?

1

There are 1 answers

0
atyc On

android.widget.MediaController is inherited from android.view.View, so that you can add android.view.View.addOnAttachStateChangeListener for attach state changes.

mediaController.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
    override fun onViewAttachedToWindow(view: View?) {
    }

    override fun onViewDetachedFromWindow(view: View?) {
    }
})