danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.38k stars 2.43k forks source link

[Bug] ffmpeg plugin giving error when including it in module's provider #4778

Open shyamal890 opened 1 month ago

shyamal890 commented 1 month ago

I'm submitting a ... (check one with "x")

Current behavior: Adding @awesome-cordova-plugins/ffmpeg 's FFMpeg to module providers gives following error:

Invalid provider for the NgModule 'AppModule' - only instances of Provider and Type are allowed, got: [?[object Object]?, ..., ..., ...]

Expected behavior:

Steps to reproduce:

  1. npm i cordova-plugin-ffmpeg @awesome-cordova-pugins/ffmpeg
  2. Added FFMpeg to AppModule (imported with import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg/ngx';)
  3. Utilize FFMpeg in a service (This can be anything)

Related code:

insert any relevant code here

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic:

   Ionic CLI                     : 7.2.0 (C:\Users\Shyamal\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 8.1.1
   @angular-devkit/build-angular : 17.3.7
   @angular-devkit/schematics    : 17.3.7
   @angular/cli                  : 17.3.7
   @ionic/angular-toolkit        : 11.0.1

Capacitor:

   Capacitor CLI      : 6.0.0
   @capacitor/android : 6.0.0
   @capacitor/core    : 6.0.0
   @capacitor/ios     : 6.0.0

Utility:

   cordova-res (update available: 0.15.4) : 0.15.2
   native-run                             : 2.0.1

System:

   NodeJS : v20.10.0 (C:\Program Files\nodejs\node.exe)
   npm    : 10.2.4
   OS     : Windows 10
MaximBelov commented 1 month ago

Hard to say

try not to use it as a provider

import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg';

shyamal890 commented 1 month ago

If I remove FFMpeg from module provider array then I get the following error when I try to utilize it in the service constructor:

taskModal.ts:165 ERROR NullInjectorError: R3InjectorError[AudioService -> AudioService -> AudioService -> [object Object] -> [object Object]]: NullInjectorError: No provider for [object Object]!

import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg/ngx';

@Injectable({
    providedIn: 'root'
})
export class AudioService {

    constructor(
        private ffMpeg: FFMpeg
    ) {

    }