Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to record audio in Android 10 #503

Closed
julia-fix opened this issue Nov 11, 2021 · 3 comments
Closed

Not able to record audio in Android 10 #503

julia-fix opened this issue Nov 11, 2021 · 3 comments

Comments

@julia-fix
Copy link

julia-fix commented Nov 11, 2021

The following code works in Android 8:

var onSuccess = function (e) {
	console.log('onSuccess', e);
};
var onError = function (e) {
	console.log('onError', e);
};
my_media = new Media(cordova.file.externalDataDirectory + 'audio.mp3', onSuccess, onError);
my_media.startRecord();

However startRecord gives an error {code: 1} in Android 10.

What have I tried with same result:

my_media = new Media(cordova.file.cacheDirectory + 'audio.mp3', onSuccess, onError);
my_media.startRecord();

my_media = new Media(cordova.file.applicationStorageDirectory + 'audio.mp3', onSuccess, onError);
my_media.startRecord();

my_media = new Media(cordova.file.dataDirectory + 'audio.mp3', onSuccess, onError);
my_media.startRecord();

I also tried to create file before recording:

resolveLocalFileSystemURL(cordova.file.externalDataDirectory , function (entry) {
	entry.getFile('audio.mp3', {
		create: true,
		exclusive: false
	}, function (fileEntry) {
		console.log('getFile', fileEntry);
                my_media = new Media(cordova.file.externalDataDirectory + 'audio.mp3', onSuccess, onError);
                my_media.startRecord();
	}, function (err) {
		console.log(err);
	});
	}, function (err) {
	console.log(err);
});

The file is created but recording does not start.
Please tell if I am doing something wrong or if this plugin is not working with Android 10+ so I will not waste my days trying to make it work.

P.S. similar issues suggests requestLegacyExternalStorage flag but it is not solving problem anymore because Play Market now requires apps to use API level 30.

@julia-fix
Copy link
Author

Sorry, posted in wrong repository.
Moved my question to apache/cordova-plugin-media#322

@ibrahimahmed
Copy link

@July- did you able to solve it facing the same issue for android 10 and 11

@julia-fix
Copy link
Author

@ibrahimahmed No, waiting for the plugin to update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants