I am trying to create a custom view that Mediaplayer is bound to. After the first frame on the screen, I want MediaPlayer to pause for a second or two, and then end the video. I have a problem trying to figure out when this first frame appears on the screen. I tried using:
MediaPlayer.start (), and then immediately after Mediaplayer.pause () - this does not work, because the system takes time to download the video, and the screen turns black when I do this.
OnBufferingUpdateListener - does not work, because it applies only to videos from the Internet
OnInfoListener MEDIA_INFO_VIDEO_RENDERING_START - The API is 17, and this is too large.
onDraw in user view - currently testing, I'm not sure how to know when video fragments are drawn.
What I'm doing now is to set a timer in my code to wait like 50 milliseconds after the timer is paused for a while. However, this is just a quick fix, not a long term fix.
I believe that the only way to solve this problem is to create some kind of custom listener or use the method that is called when video clips appear on the screen. However, my problem is that I do not know what to listen to, and I did not find a method that is called when the video starts playing. Therefore, any help in solving this problem would be greatly appreciated.
source share