3

I went through every possible resource to find a way to stop the audio play in background.

setTimeout(() => {

   //Turn off the music
   console.log('TURNING OFF MUSIC AFTER 4 MINS');

}, 240000);

Case 1: iOS Playing audio, app is put into background and even if the screen is locked , timer method turns off my music .

Case 2: Android Playing audio and app put to background , even if I set time to 30 seconds , above timeout function body is not fired.

For iOS, I got background mode turned on in capabilities in xcode. May be for that reason , setTimeout() method is working fine for me.

But in case of android , I am not able to think of a solution.

Any Solutions !!

I saw that background timer modules but I think if setTimeout() works for ios then why not for android. May be somebody has another idea.

UPDATE Can I turn off the music playing in background using local notification?

Bikram Thapa
  • 1,329
  • 1
  • 16
  • 29

1 Answers1

1

I had the only option using the background timer.

Background Timer

Hope it helps !!

Bikram Thapa
  • 1,329
  • 1
  • 16
  • 29