I m developing an Android app which can play streaming videos and navigate through the app with the video playing in background.
The video is playing on a Service and to watch the video i set the MediaPlayer
's surface to a SurfaceTexture
of a TextureView
. No problems here, this works fine.
The problem comes up when the user minimizes the player (without problem) and wants to re-open it. Here, when i re-set the Surface to the MediaPlayer the video jumps one or two seconds back and continues reproducing fine. Here is the code when i set the surface to the MediaPlayer:
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
surfaceTexture = new Surface(surface);
if (myMusicService != null) {
myMusicService.getMediaPlayer().setSurface(surfaceTexture);
}
}
I tried with a SurfaceView
too (instead a TextureView
) with the same result.
Any ideas?
Thanks,