capacitor-community / native-audio

MIT License
102 stars 62 forks source link

I cannot include this in my Ionic Capacitor project #86

Closed travisryan closed 10 months ago

travisryan commented 10 months ago

Describe the bug Whenever I add this plugin in my Capacitor project, it give me an error in PWA, iOS, Android, etc.

To Reproduce Steps to reproduce the behavior:

  1. Add the @capacitor-community/native-audio to your project (npm i @capacitor-community/native-audio)
  2. Pick a page to import it. (use "import { NativeAudio } from '@capacitor-community/native-audio';")
  3. Declare it in the constructor ( private nativeAudio: NativeAudio)
  4. See error - ERROR Error: Uncaught (in promise): SyntaxError: Unexpected token '('

Expected behavior Should have all the functionality to at least load without errors like the old Cordova Native-Audio did. I'm trying to move from Cordova to Capacitor and this is a blocker for me.

Screenshots Full Error below where I declared in my signin page: ERROR Error: Uncaught (in promise): SyntaxError: Unexpected token '(' SyntaxError: Unexpected token '(' at eval () at newTrustedFunctionForJIT (/project/node_modules/@angular/compiler/fesm2022/compiler.mjs:5641:31) at JitEvaluator.evaluateCode (/project/node_modules/@angular/compiler/fesm2022/compiler.mjs:5711:29) at JitEvaluator.evaluateStatements (/project/node_modules/@angular/compiler/fesm2022/compiler.mjs:5685:21) at CompilerFacadeImpl.jitExpression (/project/node_modules/@angular/compiler/fesm2022/compiler.mjs:25929:39) at CompilerFacadeImpl.compileFactory (/project/node_modules/@angular/compiler/fesm2022/compiler.mjs:25896:21) at SigninPage.get (/project/node_modules/@angular/core/fesm2022/core.mjs:25551:41) at getFactoryDef (/project/node_modules/@angular/core/fesm2022/core.mjs:2289:32) at configureViewWithDirective (/project/node_modules/@angular/core/fesm2022/core.mjs:12213:60) at initializeDirectives (/project/node_modules/@angular/core/fesm2022/core.mjs:11947:9) at resolvePromise (/project/node_modules/zone.js/fesm2015/zone.js:1193:31) at resolvePromise (/project/node_modules/zone.js/fesm2015/zone.js:1147:17) at /project/node_modules/zone.js/fesm2015/zone.js:1260:17 at _ZoneDelegate.invokeTask (/project/node_modules/zone.js/fesm2015/zone.js:402:31) at /project/node_modules/@angular/core/fesm2022/core.mjs:27127:55 at AsyncStackTaggingZoneSpec.onInvokeTask (/project/node_modules/@angular/core/fesm2022/core.mjs:27127:36) at _ZoneDelegate.invokeTask (/project/node_modules/zone.js/fesm2015/zone.js:401:60) at Object.onInvokeTask (/project/node_modules/@angular/core/fesm2022/core.mjs:27437:33) at _ZoneDelegate.invokeTask (/project/node_modules/zone.js/fesm2015/zone.js:401:60) at Zone.runTask (http://localhost:8100/polyfills.js:8117:37) {rejection: SyntaxError: Unexpected token '(' at eva…s>) at newTrustedFunctionForJIT (http:/…, promise: ZoneAwarePromise, zone: Zone, task: ZoneTask, stack: 'Error: Uncaught (in promise): SyntaxError: Un… (http://localhost:8100/polyfills.js:8117:37)', …}

Additional context I've done a debug step through, but not even using the plugin, is causing this issue. I've tried changing settings in tsconfig stuff per other types of issues found on Google but nothing solves it.

travisryan commented 10 months ago

This is the value it's not liking.... 'jit_SigninPage_0,jit___directiveInject_1,jit_NavController_2,jit_LoadingController_3,jit_AuthProvider_4,jit_Router_5,jit_AlertController_6,jit_NgZone_7,jit_Platform_8,jit___anonymousType() { [capacitor code] }_9'

The anonymousType() etc seems to be where I pass the NativeAudio into my constructor after importing....

travisryan commented 10 months ago

Nevermind. Figured out that we dont' need to put a declaration in the constructor. Just using the variable directly imported, NativeAudio, is the way to access it.