I am trying to play multiple videos in a loop using MediaPlayer (Android ICS) and change the video every time I call oncompletion ().
It works fine, but after a random time, the application freezes, and I get an error message:
[SurfaceView] connect: already connected (cur = 3, req = 3) setVideoSurfaceTexture failed: -22
When this error occurs, internally it calls reset player
ref: mediaplayer.cpp
if (err != OK) { LOGE("setVideoSurfaceTexture failed: %d", err); // Note that we must do the reset before disconnecting from the ANW. // Otherwise queue/dequeue calls could be made on the disconnected // ANW, which may result in errors. reset(); disconnectNativeWindow(); return err; }
according to my code, I get a notification for onprepared () and start playing.
In fact, there is no reproduction due to this error.
So, I'm trying to reset the media player and call prepare () when this problem has occurred and the media player is not playing, but I can not fix this error (mp.isPlaying () → true (bec'z called start () in onprepared () )
I try logic like
onprepared() { mp.start(); if (pbm : [SurfaceView] connect : already connected (cur=3, req=3) setVideoSurfaceTexture failed : -22 ) { reset the mediaplayer source and call prepare } }
How can I find this error to restart the media player again?
Muthuraj
source share