Media recorder in android -
hello have create small application in recording audio. problem is, in following code can create file in specific folder when trying play audio file says media file not supporting. plz help
public void startrecording() { system.out.println("start recording"); if (recorder != null) { recorder.release(); } else { recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.three_gpp); recorder.setaudioencoder(mediarecorder.audioencoder.default); recorder.setoutputfile(getfilepath()); try { recorder.prepare(); recorder.start(); } catch (illegalstateexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } { recorder.release(); } } } private void stoprecording() { system.out.println("stop recording"); try { if (null != recorder) { recorder.stop(); recorder.reset(); recorder.release(); recorder = null; } } catch (illegalstateexception e) { e.printstacktrace(); } } private string getfilepath() { file rsd = environment .getexternalstoragepublicdirectory(environment.directory_music); if (!rsd.isdirectory()) { rsd.mkdir(); } file dcim = new file(rsd + "/hello.mp3"); return dcim.getabsolutepath(); }
yup ralph house said in comment, should save file .3gp extention. change
file dcim = new file(rsd + "/hello.mp3"); to:
file dcim = new file(rsd + "/hello.3gp");
Comments
Post a Comment