oliexdev / openWorkout

Simple workout trainer that puts your privacy first
GNU General Public License v3.0
124 stars 17 forks source link

Can't play music during training. #30

Open Day-OS opened 3 years ago

Day-OS commented 3 years ago

When starting any training while listening to music, it stops the music app. If then I restart the music, it just stops again when the exercise is over.

To Reproduce Steps to reproduce the behavior:

  1. Play a song in any music app.
  2. Start the training session.

Expected behavior Simply playing both at the same time.

oliexdev commented 3 years ago

Indeed, just a quick research this is unfortunately not easy to implement.

jm355 commented 3 years ago

Maybe every time audio needs to be played, it could call a system pause, play its own sound, and then call a system play/resume? I'm not familiar enough with android dev to know if there is any kind of system call like that, but I would imagine it would be possible since in a key mapper app "Play/Pause Media Playback," "Pause Media Playback," and "Resume Media Playback" are all possible actions

oliexdev commented 3 years ago

Seems has to do with Audio Focus but my first try didn't work. Any help are welcome.

polyonymous commented 3 years ago

When starting any training while listening to music, it stops the music app. If then I restart the music, it just stops again when the exercise is over.

I was having this problem also and found a fix in adjusting the settings of the audio player being silenced. In my case this was a podcast app (https://github.com/AntennaPod/). In the playback settings it has a choice between pausing audio for interruptions or just lowering volume. After switching from pausing to lowering volume I've had no problems.

I guess this a workaround as the bug in OpenWorkout seems to be that it somehow doesn't return focus after the "interruption"? But hopefully you have a similar setting in your music app, @Day-OS .

I also use a metronome app - similar to OpenWorkout in using intermittent noises - which doesn't have this issue of stopping audio playback even with the "pause for interruptions" setting. That app is Chubby Click (https://codeberg.org/agrigolo/chubby-click), in case it's useful to look at how it handles audio.

I love OpenWorkout, BTW, it's helping a lot with my rehab from a prolapsed cervical disc. Thanks so much @oliexdev for your work. I'd contribute if I knew anything about programming. But maybe I'm right in guessing the app is originally in German? Wenn ja, könnte ich zukünftig etwas übersetzen...