-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: player plays last initialized sound after finishing a call #111
Comments
I found the cause of this bug. On Android every time AUDIOFOCUS_GAIN is fired on AudioManager, resume() is called even though the player was not playing when focus was lost. |
Did you get a workaround? |
I did. I commented out the line and now use a local copy of the plugin. Quick and dirty but unfortunately no time to contribute. |
nativescript-audio/src/android/player.ts Line 393 in 02017d8
@jnorkus, that line? @NathanWalker, how can we improve this? Do you have any suggest? |
Yes exactly that one. |
Any news on this guys? |
So I tested this with the this.resume() commented out as mentioned above and the audio still played and when I receive notifications it would play the sound. So I'm not sure what the fix is. This is a pretty big bug though. |
Any news about this? :/ |
My work around for this (in a local version of the plugin) was to make the following edits in
Tried making the subsequent changes in the plugin itself, but after compiling and running the demo, i'm getting an extra |
Otherwise, the above edits work in my actual app. |
I think I have an issue relative to this one. Player plays last initialized audio after colling and closing Google Assistant. This thing helped:
|
I had exactly the same problem. Player plays last initializes audio even the app is in background when receives call or notification. #111 (comment) helped. |
In my case, this answer fixed it 👍🏽 |
Previously audio focus was requested by the playFromFile method, which is called during initFromFile and initFromUrl. Getting audio focus this early means that when an AUDIOFOCUS_GAIN event is received, the track will start playing even though the caller never requested it to play. Now the audio focus is not requested until playing the track. Fixes #111
To reproduce, add this code, then receive and finish a phone call. The audio file is played immediately.
The text was updated successfully, but these errors were encountered: