android - MediaPlayer prepare fail IOException -
my question having many mediaplayers cause ioexception preparefailed: status= 0x1 log?
the way program running use separate instance of media player each video want play. @ end of run stop videoplayer, release it, , turn null; ok other times when move between video's fast io exception , video not play. have mediaplayer playing background music in service.
basically video activity gets new call each time file ends playback. error , should try reuse same media player different file?
thanks in advance
i found own answer. don't know if way but:
if(videofile != null) { log.i("initplayer", videofile); afd = getassets().openfd(videofile); instructionvideoplayer = new mediaplayer(); instructionvideoplayer.setdatasource(afd.getfiledescriptor(), afd.getstartoffset(), afd.getdeclaredlength()); instructionvideoplayer.setdisplay(holder); instructionvideoplayer.prepare(); instructionvideoplayer.setoncompletionlistener(instructionvideocomplete); instructionvideoplayer.setonpreparedlistener(this); } else log.i("videoplayer", "novideofile"); } catch (illegalargumentexception e) { e.printstacktrace(); } catch (illegalstateexception e) { e.printstacktrace(); } catch (ioexception e) { log.i(this.tostring(), "ioexception"); e.printstacktrace(); //here fix: instructionvideoplayer.release(); instructionvideoplayer = null; initplayer(); // reinit after prepare failed. although can bring in infinte loop if video file not exits } catch (exception e) { log.i("initplayer", e.getclass().tostring()); e.printstacktrace(); }
Comments
Post a Comment