How to record call in android ? (old methods not working) -


asking questions quickly.

mediarecorder = new mediarecorder();     mediarecorder.setaudiosource(mediarecorder.audiosource.mic);     mediarecorder.setoutputformat(mediarecorder.outputformat.mpeg_4);     mediarecorder.setaudioencoder(mediarecorder.audioencoder.aac);     mediarecorder.setoutputfile((audiofile.getabsolutepath())); 

this code works on note5 not on s8+. cannot record other sides voice.

i cant use audiosource.voice_call or audiosource.voice_downlink , audiosource.voice_uplink because of capture_audio_output permission problem.

but acr app record conversations possible.

note: not think format or encoder related topic

full code:

private void startrecord() {      mediarecorder = new mediarecorder();     long tslong = system.currenttimemillis() / 1000;     string ts = tslong.tostring();      file recorddirectory = new file(environment.getexternalstoragedirectory().tostring() + "/callrecord");      if (!recorddirectory.isdirectory()) {         recorddirectory.mkdirs();     }      audiofile = new file(environment.getexternalstoragedirectory().tostring() + "/callrecord",             ts + ".aac");      recordedfilepath = audiofile.getpath();     recordinfo.recordpath = recordedfilepath;      tslong = null;     ts = null;     mediarecorder = new mediarecorder();     mediarecorder.setaudiosource(mediarecorder.audiosource.mic);     mediarecorder.setoutputformat(mediarecorder.outputformat.mpeg_4);     mediarecorder.setaudioencoder(mediarecorder.audioencoder.aac);     mediarecorder.setoutputfile((audiofile.getabsolutepath()));      try {         mediarecorder.prepare();         mediarecorder.start();     } catch (ioexception e) {         e.printstacktrace();     }  }   private void stoprecord() {     mediarecorder.stop();     mediarecorder.release(); } 

start audio recording

 public void startaudiorecording(view view) throws ioexception {           //create file save recording         file dir = environment.getexternalstoragedirectory();           try {             audiofile = file.createtempfile("sound", ".3gp", dir);           } catch (ioexception e) {             log.e(tag, "external storage access error");             return;           }           mrecorder = new mediarecorder();           mrecorder.setaudiosource(mediarecorder.audiosource.mic);           mrecorder.setoutputformat(mediarecorder.outputformat.three_gpp);           mrecorder.setaudioencoder(mediarecorder.audioencoder.amr_nb);           mrecorder.setoutputfile(audiofile.getabsolutepath());           mrecorder.prepare();           mrecorder.start();         }   

stop audio recording

 public void stopaudiorecording(view view) {           mrecorder.stop();           mrecorder.release();         }   

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -