简体   繁体   中英

Cordova audio recording issues in some devices phonegap media plugin

I'm developing one simple application using phonegap for Android devices, in which one of the functionality is Audio Recording. The snippet to capture voice is as below -

function captureAudio() {
        navigator.device.capture.captureAudio(captureSuccess, captureError, { limit: 1, duration: 60 });
    }

The application is running as expected in Samsung Tab 2 (Android version 4.1.2) & Samsung Mega (Android version 4.2.2) and user can able to record the voice.

The same application I had deployed on Lenovo A 1000 (Android version 4.1.2) and Samsung Tab 3 Neo (Android 4.2.2) but default voice recorder is not opening and I'm getting following error in logcat -

In Cordova 3.x version:- android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.provider.MediaStore.RECORD_SOUND }

In Cordova 2.8 version:

Error code 3.

As above the application running well on Android 4.1.2 & 4.2.2 on some devices and not running on some devices having same version.

Then I'd tried native sound recorder sample (downloaded from http://krvarma-android-samples.googlecode.com/svn/trunk ) and it is working well in all devices.

So, the finding is there is some problem in Media plugin of phonegap.

However, we can built our own plugin to record the voice but if it can be resolved through standard plugin then it would be better.

Any help ?

Regards Indra Bisen

Judging from the code sample you linked, i assume you are using the org.apache.cordova.media-capture plugin. I ran into the same problem using this plugin, and found that it is not working if the device doesn't have a default voice recorder.

The only way i found to avoid this is to use the plugin org.apache.cordova.media , which is a little different because you'll have to create the recording UI yourself.

I can also redirect you on this question for a code sample for this plugin, it talks about the same problem as yours.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM