captbaritone / webamp

Winamp 2 reimplemented for the browser
https://webamp.org
MIT License
10.2k stars 685 forks source link

Allow music to be played in background for Safari on iOS #1279

Open maaaaz opened 2 weeks ago

maaaaz commented 2 weeks ago

Hello and thank you for this amazing project !

To date, when playing audio from Safari on iOS, webamp music can't be played in the background. Not even with this "manually playing with the control center" trick.

I am not talking about autoplay, but only playing in the background after pressing the "play" button.

A lot of web-based players can play in the background, for instance the native player on archive.org. I am clueless about HTML/JS but it seems that Safari on iOS needs a proper <audio> tag in the HTML of the web page.

Can you adapt webamp to allow playing in background ?

Cheers!

captbaritone commented 2 weeks ago

I'm happy to look into this if someone can identify exactly what it is within Webamp that's causing it to not be playable in the background, or if someone is able to find some documentation about under which conditions iOS lets a webpage play audio in the background.

bitviper8299 commented 2 weeks ago

i think i found out what it is. so iPhone doesnt like javascript. you can enable it to run on mobile iOS, but the problem is is that it doesnt like javascript running in the background, ie when you swipe out. i ben trying to figure out ways into tricking it by messing w audio tags, basically trying to make it seem like its html audio coming from the site rather than java. am i making sense?

captbaritone commented 2 weeks ago

Sadly I don't think that will work. Webamp must attach JavaScript listeners to the audio output in order to do balance, eq, visualizers. Probably not very practical to disable all that stuff.

bitviper8299 commented 2 weeks ago

yea i assumed so, ive been trying to find ways to trick the browser into thinking html audio is playing, im going to try having an html file with silence just loop in the background when the site is opened, and maybe that can trick it?

maaaaz commented 2 weeks ago

Thank you all for quickly looking at this issue.

Sadly I don't think that will work. Webamp must attach JavaScript listeners to the audio output in order to do balance, eq, visualizers. Probably not very practical to disable all that stuff.

If we could have, from a user point of view, a webamp "simple" mode where these advanced features of equalizer etc. can be turned off (thanks to a button/switch or whatever), in favor of being able to play in the background, it could be great !

Again, I am totally clueless in HTML/JS and iOS stuff, but I found these:

And again, the native media player from archive.org works correctly with Safari on iOS for background music: https://github.com/internetarchive/iaux-music-player