android - How to use getfiledescriptor with setdatasource -


how should pass in setsourcefile work correctly. want record , play audio concurrently.

here code:

public class mainactivity extends actionbaractivity {  string outputfile; mediarecorder recorder; mediaplayer player; parcelfiledescriptor[] pfd; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     recorder = new mediarecorder();     pfd = new parcelfiledescriptor[0];     try {         pfd=parcelfiledescriptor.createpipe();     } catch (ioexception e) {         e.printstacktrace();     }   }   public void start(view v) throws ioexception {     recorder.setoutputfile(pfd[1].getfiledescriptor());//this working     recorder.setaudiosource(mediarecorder.audiosource.mic);    recorder.setoutputformat(mediarecorder.outputformat.three_gpp);    recorder.setaudioencoder(mediarecorder.outputformat.amr_nb);     try {          recorder.prepare();         } catch (ioexception e) {                                   e.printstacktrace();                                 }    recorder.start();    mediaplayer   player = new mediaplayer();    try {         player.setdatasource(pfd[0].getfiledescriptor());// not working         }catch (ioexception e) {                                e.printstacktrace();                               }  //this exception:  // java.io.ioexception: setdatasourcefd failed.: status=0x80000000         plater.prepare();         player.start();      } 

is there way transfer audio recorder speaker?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -