Closed Tronix117 closed 6 years ago
I add success using "nativescript-videorecorder@2.0.4" and manualy requesting permissions like so:
if (isAndroid) {
await requestPermissions([
(<any>android).Manifest.permission.WRITE_EXTERNAL_STORAGE,
(<any>android).Manifest.permission.RECORD_AUDIO,
(<any>android).Manifest.permission.CAMERA
])
}
Ok So update on this issue:
Android Manifest should have (in the <application>
):
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="fr.wikodit.prosapiens.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
Then in the file App_Resources/xml/provider_paths.xml
you should have (it does not seem to pick the one in the module, I had to manualy create it):
<?xml version="1.0" encoding="utf-8"?>
<paths
xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="videos" path="." />
<cache-path name="temps_videos" path="."/>
</paths>
Then the module code needs to be modified a bit like so:
if (!options.saveToGallery) {
if (sdkVersionInt >= 21) {
path = app.android.currentContext.getExternalFilesDir(null);
file = new java.io.File(path, fileName);
tempPictureUri = android.support.v4
.content.FileProvider.getUriForFile(app.android.foregroundActivity, pkgName + '.provider', file);
}
else {
path = fs.path.join(fs.knownFolders.temp().path, fileName);
file = new java.io.File(path);
tempPictureUri = android.net.Uri.fromFile(file);
}
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPictureUri);
}
Also path = app.android.currentContext.getExternalFilesDir(null);
may be conditionaly determined using a configuration variable, depending on cases, we may not want to store it in a temporary location. Or maybe we keep it simple, and if the developer want to move it in another location, it can do it like he have the path ?
I used getExternalFilesDir
instead of a temp directory, because it was easier for me to test, it should work with the temp directory
If the demo apps cannot help and there is no issue for your problem, tell us about it
Can not start the videorecorder on Android, working fine on iOS.
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
Is there any code involved?
Here is the call to the videorecorder:
I have this in AndroidManifest.xml:
Here is the error: