android - Exception when calling setDataSource(FileDescriptor) method (failed.: status=0x80000000) -


i'm developing video streaming application , i'm getting stuck when calling set setdatasource filedescriptor. want application play video being downloaded, once minimum number of bytes, move bytes file can played in file while it's being downloaded in original file.

so, check if can start media palyer every packet this:

if (mediaplayer == null) {                     // create mediaplayer once have minimum                     // buffered data                     if (totalkbread >= intial_kb_buffer) {                         try {                             startmediaplayer();                         } catch (exception e) {                             log.e(getclass().getname(),                                     "error copying buffered conent.", e);                         }                     }                 } else if (mediaplayer.getduration()                         - mediaplayer.getcurrentposition() <= 1000) {                     transferbuffertomediaplayer();                 } } 

this startmediaplayer method code:

private void startmediaplayer() {         try {             file bufferedfile = new file(context.getcachedir(), "playingmedia"                     + (counter++) + ".dat");              // bufferedfile 1 that'll played             movefile(downloadingmediafile, bufferedfile);              mediaplayer = createmediaplayer(bufferedfile);              mediaplayer.start();              playbutton.setenabled(true);         } catch (ioexception e) {             log.e(getclass().getname(), "error initializing mediaplayer.",                     e);             return; } 

i move file following code:

public void movefile(file oldlocation, file newlocation) throws ioexception {          if (oldlocation.exists()) {             bufferedinputstream reader = new bufferedinputstream(                     new fileinputstream(oldlocation));             bufferedoutputstream writer = new bufferedoutputstream(                     new fileoutputstream(newlocation, false));             try {                 byte[] buff = new byte[8192];                 int numchars;                 while ((numchars = reader.read(buff, 0, buff.length)) != -1) {                     writer.write(buff, 0, numchars);                 }             } catch (ioexception ex) {                 throw new ioexception("ioexception when transferring "                         + oldlocation.getpath() + " "                         + newlocation.getpath());             } {                 try {                     if (reader != null) {                         writer.flush();                         writer.close();                         reader.close();                     }                 } catch (ioexception ex) {                     log.e(getclass().getname(),                             "error closing files when transferring "                                     + oldlocation.getpath() + " "                                     + newlocation.getpath());                 }             }         } else {             throw new ioexception(                     "old location not exist when transferring "                             + oldlocation.getpath() + " "                             + newlocation.getpath());         }     } } 

and create mediaplayer object here:

private mediaplayer createmediaplayer(file mediafile) throws ioexception {          if(mediaplayer != null){             mediaplayer.release();         }          mediaplayer mplayer = new mediaplayer();         mplayer.setonerrorlistener(new mediaplayer.onerrorlistener() {             public boolean onerror(mediaplayer mp, int what, int extra) {                 log.e(getclass().getname(), "error in mediaplayer: (" +                         + ") (" + + ")");                 return false;             }         });          // appears security/permission reasons, better pass         // filedescriptor rather direct path file.         // have seen errors such "pvmferrnotsupported" ,         // "prepare failed.: status=0x1" if file path string passed         // setdatasource().         fileinputstream fis = new fileinputstream(mediafile);          mplayer.reset();         filedescriptor fd = fis.getfd();         mplayer.setdatasource(fd);       // im getting exception here         mplayer.setdisplay(mholder);         mplayer.prepare();         return mplayer;     } 

this excepction get:

01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229): error initializing mediaplayer. 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229): java.io.ioexception: setdatasourcefd failed.: status=0x80000000 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ android.media.mediaplayer.setdatasource(native method) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ android.media.mediaplayer.setdatasource(mediaplayer.java:854) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ org.pfc.utils.streamingmediaplayer.createmediaplayer(streamingmediaplayer.java:266) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ org.pfc.utils.streamingmediaplayer.startmediaplayer(streamingmediaplayer.java:226) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ org.pfc.utils.streamingmediaplayer.access$4(streamingmediaplayer.java:203) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ org.pfc.utils.streamingmediaplayer$2.run(streamingmediaplayer.java:183) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ android.os.handler.handlecallback(handler.java:587) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ android.os.handler.dispatchmessage(handler.java:92) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ android.os.looper.loop(looper.java:144) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ android.app.activitythread.main(activitythread.java:4937) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ java.lang.reflect.method.invokenative(native method) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ java.lang.reflect.method.invoke(method.java:521) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 01-25 16:03:15.663: error/org.pfc.utils.streamingmediaplayer(2229):     @ dalvik.system.nativestart.main(native method) 

i've been whole morning stuck here , find no information on error. people have told me use file path, other exception talk in comments (right on fileinputstream creation).

i'm lost here, appreciated

don't forgot permission

<uses-permission android:name="android.permission.internet" />  

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -