开发者

PhoneGap Android plugin for higher quality audio recording?

The PhoneGap media API provides a mechanism to reco开发者_JAVA技巧rd audio in a cross-platform way which works on android, but the audio quality is completely horrible -- 8 kHz sampling rate and perhaps some highly lossy codec as well. I understand from this SO question that with java code it's possible to get higher quality audio recording.

Anybody know of a PhoneGap plugin for Android that allows for higher quality audio recording?


For anyone interested, what we did was dropping support for anything less than Android 2.3 and modify the Cordova native code ourselves.

If you are using Cordova 3+, I forked the project with the code changes here

For previous releases, just modify AudioPlayer.java (this is from Cordova 2.9)

 // support only 2.3.3+ to be able to record AAC with 44100 audio sampling
 this.recorder.setAudioSamplingRate(44100);
 this.recorder.setAudioEncodingBitRate(96000);
 this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
 this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

 //this.recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);// THREE_GPP);
 //this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);// //AMR_NB);


You will have to write your own plugin unfortunately.

Here a list of current plugins: https://github.com/phonegap/phonegap-plugins/tree/master/Android

For IOS there is an older audio record one. Maybe you can have a look there:

https://github.com/phonegap/phonegap-plugins/tree/master/iOS/AudioRecord

Creating a plugin is not such a big deal though. Here some code for the actual recording:

http://www.androiddevblog.net/android/android-audio-recording-part-2

http://developer.android.com/reference/android/media/AudioRecord.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜