Closed iMackshun closed 3 years ago
Hmmz, that's a first... I have never had, seen or even heard about an issue like this.
Starting further into the video could happen for several reasons. The first being something in the MediaPlayer, but you seem to have ruled it out already. Another issue could be that the event from the MediaPlayer does not arrive to the application in time. This could happen if the Looper thread is busy.
Could it be that you are heavily using the looper thread on android, causing the events to be delayed?
No. I'll try running a blank project with just the video playback to see if the issue can be replicated, in my case.
...OK. So the problem isn't in the test project, so it must be something that I am doing incorrectly in my main project. With this information, I'm assuming the render() method is only for the drawing aspect, and it is updated elsewhere? Meaning, say, it I want to play the video after a delay, I'd have to initialize it whenever I need the video to begin playing?
The behaviour of the render method is quite different on desktop and android. This is because we must handle the encoding ourselves on desktop, while on android some other thread will start rendering in realtime.
This means that on desktop, calling render actually decodes new frames, adds audio to the audio buffers, retrieves the frame for the current timestamp and copies it to a texture, which is then displayed. On android, the player receives an event if a new frame is rendered, and sets a simple boolean flag. When render() is called, this flag is checked and if there is a new frame available, the mediaplayer is asked to update the texture (On the gpu itself, saving a lot of bandwidth). The timing of when the video starts is on android completely depending on when the mediaplayer starts playing (Which could be instantly after the play() method on our gdx-video player). However, no frame will be displayed before calling render().
If your first render() takes place 5 seconds after your play(), it would mean that the video might be playing for 5 seconds with audio, and a black screen since the first frame was never put into a texture,
Could you try if the issue persists with the newest snapshot?
After trying various formats, gdx-video seems to work perfectly on desktop. On Android, the video plays just fine, but whenever the video begins playback, it is consistently about 5 seconds into the video, thus causing the first few seconds of the video to be omitted. I've tried using some different formats, just in case it was just .webm videos, but encoding in other formats produces the same or worse results.(Black screen with....ogv on Android, I believe. I'll just stick to .webm) Whenever I playback the same video in Android's Media Player, it works just fine. One solution would be to add a delay at the beginning of each video, but that isn't very elegant. I tried poking around the code to see if there is something that I can call to reset the video once it is loaded, but that hasn't gotten me anywhere. lol I My current game focuses on audio-video sync, so this harms the experience on Android. Any clues as to why it starts so far into the video?