Cordova-plugin-video-editor on Android 8.x

Hello

I’m using cordova-plugin-video-editor, to transform compress videos in storage, before they uploaded to a service.

The plugin works fine in iOS and in Android up to version 6.x

In Android version 8.1 (not sure if it is the same in 8.0). When I launch the plugin, I get an exception. “Can’t access or make Movies directory”.

  • Anyone had the same problem or a workaround with the specific plugin?

I’m also dealing with another problem with the same plugin in Android 7.1. As I explain here.

  • Anyone know any alternatives to transcode recorded videos in order to minimize their size?

Thank you

Did you asked for permission to write external storage? Android 8 need to have an inline check for permission (not only in manifest) this is why it worked in older android versions because it use permissions from manifest and maybe this plugin dont have requestPermission method, some other plugins have both methods(manifest and Inline requestPermission checker) this is why you never faced this problem with other plugins, to solve this you can use AndroidPermissions, here is how I do it:

import { Injectable } from '@angular/core';
import { AndroidPermissions } from '@ionic-native/android-permissions';

@Injectable()
export class PermissionService {
    constructor (private androidPermissions: AndroidPermissions) {

    }

    requestNecessaryPermissions () {

        // Change this array to conform with the permissions you need
        let androidPermissionsList = [
            this.androidPermissions.PERMISSION.CAMERA,
            this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION,
            this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE,
            this.androidPermissions.PERMISSION.READ_PHONE_STATE
        ];

        return this.androidPermissions.requestPermissions(androidPermissionsList);
    }
}

And in your component, use the service like that

this.permissionService.requestNecessaryPermissions().then(() => {
    // open plugin here, after user agreed to permissions
});

1 Like

Many thanks… your suggestion solves the issue. :slight_smile:

1 Like

Hi killerchip! I am using the Diagnostic plugin and inside the response of the promise i use another plugin to save a base64 string into gallery.
If I switch manually the external storage permission. It works.
Dynamically by the Diagnostic plugin not, but the plugin`s response is “GRANTED”.
Any idea?
Sorry for my English

Hello

Apologies but it’s been some time since I touched Ionic, since my latest projects are not related to it :-(.
So I don’t remember much…

But did you check the Cordova’s config.xml (or whatever it is called… can’t remember)? I think you should have requested the access rights there (static request on build), in addition to dynamic rights requested inside your app flow.

Hope I helped…

May You’re talking about androidManifest.xml
I put the static permission there and still not working

Manifest.xml will get overwritten with each build.

You will need to change Cordova’s config.xml for sure