nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

Android only error with NS7 #178

Closed bradrice closed 3 years ago

bradrice commented 3 years ago

I've migrated my app to NS7 and one issue I am having is on android. I have an app that has mp3 files associated with lessons. You click through the lessons and pull a new mp3 using a rest service. All of that works fine. What isn't working is I have one template in the lesson sequence that uses a carousel on the same page. When I get to the end of a track, I send a notify click even to advance the slide and start a new audio with image. It was working fine in NS6, but in NS7 I am getting this error on Android only.

ERROR ERROR Error: Uncaught (in promise): Error: java.lang.IllegalArgumentException: Illegal null AudioFocusRequest JS: _abandonAudioFocus(file: node_modules\nativescript-audio\android\player.js:289:0) at (file: node_modules\nativescript-audio\android\player.js:120:0) JS: at ZoneAwarePromise(file: node_modules\@nativescript\zone-js\zone-nativescript.js:902:0) JS: at playFromFile(file: node_modules\nativescript-audio\android\player.js:83:0) JS: at (file: node_modules\nativescript-audio\android\player.js:133:0) JS: at ZoneAwarePromise(file: node_modules\@nativescript\zone-js\zone-nativescript.js:902:0) JS: at playFromUrl(file: node_modules\nativescript-audio\android\player.js:132:0) JS: at playAudioTrack(file: app\core\services\player.service.ts:553:13) JS: at (file: app\pages\player\templates\carousel\carousel.component.ts:268:35) JS: at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.ZoneDelegate.invoke(file:///data/data/com.too

bradrice commented 3 years ago

I'm closing this. I think it was my own code in calling the playFromURL before it was ready.

bradrice commented 3 years ago

I am reopening this with new info. This seems to throw an error anytime the audio finishes, even if it finishes on it's own.

Unhandled Promise rejection: java.lang.IllegalArgumentException: Illegal null AudioFocusRequest ; Zone: ; Task: null ; Value: Error: java.lang.IllegalArgumentException: Illegal null AudioFocusRequest _abandonAudioFocus(file: node_modules\nativescript-audio\android\player.js:289:0) JS: at (file: node_modules\nativescript-audio\android\player.js:217:0) JS: at ZoneAwarePromise(file: node_modules\@nativescript\zone-js\zone-nativescript.js:902:0) JS: at dispose(file: node_modules\nativescript-audio\android\player.js:210:0) JS: at onError(file: node_modules\nativescript-audio\android\player.js:342:0)

bradrice commented 3 years ago

The resume function is also failing to gain audio focus.

START JS: LOG {"_mAudioFocusGranted":false,"_mOnAudioFocusChangeListener":null,"_durationHint":1,"debug":true,"_options":{"audioFile":"https://toolingu.com/lms/multi_media/audio/100106_2.mp3","loop":false,"autoPlay":true},"_audioFocusRequest":null,"_mediaPlayer":{},"_events":{"_observers":{}}} JS: ERROR ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: Illegal null focus listener JS: _requestAudioFocus(file: node_modules\nativescript-audio\android\player.js:268:0) JS: at (file: node_modules\nativescript-audio\android\player.js:155:0) JS: at ZoneAwarePromise(file: node_modules\@nativescript\zone-js\zone-nativescript.js:902:0) JS: at play(file: node_modules\nativescript-audio\android\player.js:152:0) JS: at resumePlaying(file: app\core\services\player.service.ts:654:17) JS: at toggleAudio(file: app\pages\player\audioControls\audio-controls.component.ts:270:39) JS: at AudioControlsComponent_Template_Button_tap_10_listener(file: app\pages\player\audioControls\audio-controls.component.html:12:83) JS: at executeListenerWithErrorHandling(file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:15214:0) JS: at wrapListenerIn_markDirtyAndPreventDefault(file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:15249:0)

And I'm also getting the same issue when I run the demo app.

baybal commented 3 years ago

Confirming the issue at 6.2.0

bradmartin commented 3 years ago

@bradrice try 6.2.1 demo app seems to be functioning correctly with the fix.

bradrice commented 3 years ago

I am able to get 6.5.3 to work correctly. Will there be a fix for 7 coming?

bradmartin commented 3 years ago

7? I meant the version of this plugin :) 6.2.1 was just published. The latest version will work with NS7, demo app confirmed working with the bug fix just pushed and published.

bradrice commented 3 years ago

Ah, thank you so much. I’ll check it out.

On Wed, Dec 16, 2020 at 10:59 AM Brad Martin notifications@github.com wrote:

7? I meant the version of this plugin :) 6.2.1 was just published.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nstudio/nativescript-audio/issues/178#issuecomment-746531268, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACCPYBHNUTV5AWN6B5YGK3SVDKOVANCNFSM4UNSGL5A .

-- Brad Rice bradrice1@gmail.com