webamp icon indicating copy to clipboard operation
webamp copied to clipboard

Allow music to be played in background for Safari on iOS

Open maaaaz opened this issue 1 year ago • 6 comments

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!

maaaaz avatar Oct 08 '24 21:10 maaaaz

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.

captbaritone avatar Oct 08 '24 22:10 captbaritone

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?

bitviper8299 avatar Oct 08 '24 22:10 bitviper8299

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.

captbaritone avatar Oct 09 '24 00:10 captbaritone

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?

bitviper8299 avatar Oct 09 '24 00:10 bitviper8299

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:

  • https://github.com/jellyfin/jellyfin-web/issues/6113
  • https://bugs.webkit.org/show_bug.cgi?id=198277
  • https://stackoverflow.com/questions/9811429/html5-audio-tag-on-safari-has-a-delay
  • https://www.vindit.dk/play-audio-on-demand-in-safari-on-ios/
  • https://github.com/goldfire/howler.js/issues/239
  • https://stackoverflow.com/questions/14414654/stop-html5-audio-from-looping-when-ios-safari-is-closed
  • https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari/
  • https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Introduction/Introduction.html
  • https://github.com/advplyr/audiobookshelf/issues/2655
  • https://discussions.apple.com/thread/253331448?sortBy=rank
  • https://www.reddit.com/r/jailbreak/comments/kdaqvu/question_safari_audio_with_phone_locked/?rdt=36668

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

maaaaz avatar Oct 09 '24 07:10 maaaaz

Any chance to have some fix ?

maaaaz avatar Nov 13 '24 09:11 maaaaz