Home > Mobile >  Android10 version in the process of using the MediaRecorder call recording voice, hang up the phone
Android10 version in the process of using the MediaRecorder call recording voice, hang up the phone

Time:10-15

Android10 version using the MediaRecorder in the process of call recording voice, after hang up the phone to record the voice is normal, the in the lower version works , use different brand mobile phone test is the same problem, which to know why the words of the great god, thank you!

The tape code is as follows:
 
The MediaRecorder mMediaRecorder;
The File mRecorderFile;
Long startRecorderTime stopRecorderTime;
Handler mHander;
Public Boolean doStart () {

Try {
//create the MediaRecorder
MMediaRecorder=new MediaRecorder ();
//create the recording file
MRecorderFile=new File (Environment. External.getexternalstoragedirectory () getAbsolutePath ()
+ "/recorderdemo/" + System. CurrentTimeMillis () +" mp4 ");
if (! MRecorderFile. GetParentFile (). The exists ()) mRecorderFile. GetParentFile (). The file.mkdirs ();
MRecorderFile. CreateNewFile ();


//configuration MediaRecorder

//from the microphone acquisition
MMediaRecorder. SetAudioSource (MediaRecorder. AudioSource. MIC);

//save the file to MP4 format
MMediaRecorder. SetOutputFormat (MediaRecorder. OutputFormat. MPEG_4);

//all the android systems support the sampling frequency of moderate
MMediaRecorder. SetAudioSamplingRate (44100);

//general AAC encoding format
MMediaRecorder. SetAudioEncoder (MediaRecorder. AudioEncoder. The AMR_NB);

//set the tone frequency
MMediaRecorder. SetAudioEncodingBitRate (96000);

//set the documents recording the location of the
MMediaRecorder. SetOutputFile (mRecorderFile getAbsolutePath ());


//start the recording
MMediaRecorder. Prepare ();
MMediaRecorder. Start ();
StartRecorderTime=System. CurrentTimeMillis ();

} the catch (Exception e) {
//Toast. MakeText (MediaRecordActivity. This "recording failure, please try again," Toast. LENGTH_SHORT), show ();
return false;
}


//records began recording time for statistics and length less than 3 seconds, the tape does not send

return true;
}

/* *
* close recording
*
* @ return
*/
Public Boolean doStop () {
Try {
MMediaRecorder. Stop ();
StopRecorderTime=System. CurrentTimeMillis ();
Final int second=(int) (stopRecorderTime - startRecorderTime)/1000;
//hold time is less than 3 seconds, count admit failure, do not send
If (second & lt; 3) return false.
MHander. Post (new Runnable () {
@ Override
Public void the run () {
//tv_sendmsg. SetText (" recording success: "+ second +" seconds ");
}
});

} the catch (Exception e) {
e.printStackTrace();
}
return true;
}

CodePudding user response:

What a great god to a train of thought,
  • Related