Cap-go / native-audio

Capacitor plugin for native audio engine.
https://capgo.app
MIT License
35 stars 16 forks source link

Play in Background #11

Closed asudevprj closed 1 year ago

asudevprj commented 1 year ago

Describe the bug In background mode, play does not work e.g. an audible alarm can not be played.

To Reproduce Steps to reproduce the behavior:

  1. Switch an App off (Background) the sound stops playing.
riderx commented 1 year ago

In Capacitor the app will be paused by your device when background the app. That why it stop i believe.

What's the usage for sound in background ?

asudevprj commented 1 year ago

In my case, the app receives geolocation signals in the background (background geolocation plugin) and prosesses them. Wenn certain conditions are calculated, the app should play a sound. It would be great, if native-audio could offer a solution for this.

riderx commented 1 year ago

What plugin do you use for geoloc ? if you can provide a reproduction repo, i can try

asudevprj commented 1 year ago

Thank you very much for your support!

I am using the following plugin: https://github.com/capacitor-community/background-geolocation

I do not well understand the background behaviour. Does a timer still run for a short time, after app is switched into background ? Then the behaviour could be reproduced / testet with a timer (e.g. 10 seconds) that tries to play the sound?

riderx commented 1 year ago

Usually apps have 5-10 sec of runtime after backgrounding

So timer would make it, but if you do a reproduction make it work with background-geoloc then i can test exactly in your setup

asudevprj commented 1 year ago

In my opinion, testing without geolocation is easier. One never knows exactly, when a geolocation event occurs, you have to move your smartphone, etc... If native-audio could made be working by using the timer/background approach, I could test it afterwards in my bigger geolocation setting.

riderx commented 1 year ago

The geoloc plugin has the ability to wake the app, so it's way different than a settimer.

There plenty of option to simulate geoloc for dev no worry.

App MVP builder at Forgr https://forgr.ee/ Podcast host at INDIE MAKERS https://indiemakers.fr Maker of Captime https://captime.app Crossfit timer app Creator of Capgo https://capgo.app/ Capacitor OTA system

On December 16, 2022, Martin DONADIEU @.***> wrote:

In my opinion, testing without geolocation is easier. One never knows exactly, when a geolocation event occurs, you have to move your smartphone, etc...  If native-audio could made be working by using the timer/background approach, I could test it afterwards in my bigger geolocation setting.

— Reply to this email directly, view it on GitHub https://github.com/Cap- go/native-audio/issues/11#issuecomment-1354524056, or unsubscribe https://github.com/notifications/unsubscribe- auth/AA7FGL25FAGOCGQDJIOYAQLWNRAERANCNFSM6AAAAAAS626I7E. You are receiving this because you commented.Message ID: <Cap-go/native- @.***>