advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
6.17k stars 431 forks source link

[Bug]: iOS Background audio stops at the end of each audio track (iOS 17+) #2655

Open thearrow opened 6 months ago

thearrow commented 6 months ago

Describe the issue

Love the software so far!

I'm running into a minor issue using the web interface through the Orion browser on iOS (because the iOS app beta is "full", I can't use the iOS app).

If I start playback via the web interface and then switch to a different app, playback stops at the end of the current chapter (every ~10min for my current book) and I can't get it to continue without going back to the web interface and re-toggling playback. This proves to be an annoying issue (and a safety concern) while driving on a long road trip, for example.

I have "Auto Play" checked in the "Player Queue" and I couldn't find any other settings related to this behavior. In the Orion browser settings, I have "Background Audio" enabled (it works perfectly except at chapter boundaries), and all of the "Power Saving" / tab sleeping settings disabled and this behavior still happens.

I'm assuming this would not be an issue if I was able to use the proper iOS app (but the beta is "full"). Was mainly curious if anyone else had run into this issue and had any fixes/workarounds.

Thanks for the great software! Feel free to close this and I can move it to "Discussions" if that is a more suitable place for it.

Steps to reproduce the issue

  1. Open audiobookshelf web interface in Orion browser on iOS
  2. Start playing an audiobook
  3. Switch to another app (e.g. Maps, while driving)
  4. Listen successfully for ~10min or so, until the chapter ends
  5. Playback "stops" and can only be resumed by switching back to the web interface, hitting "pause" and then "play"

Audiobookshelf version

v2.7.2

How are you running audiobookshelf?

Docker

advplyr commented 6 months ago

This must be an issue with the browser not allowing it to switch audio tracks while it is in the background. If you have a single file m4b audiobook with chapters I would guess that it would move to the next chapter.

Have you tried installing the website as a PWA?

thearrow commented 6 months ago

This must be an issue with the browser not allowing it to switch audio tracks while it is in the background. If you have a single file m4b audiobook with chapters I would guess that it would move to the next chapter.

Ah, yep - this was happening with a book split into many mp3 files. Will try with a single m4b and see what happens.

Have you tried installing the website as a PWA?

Not yet, but I’ll try this soon, too!

ryc111 commented 6 months ago

Similar issue found on iOS with chrome or safari, tried two scenarios:

thearrow commented 6 months ago

I was able to verify the behavior @ryc111 described above ^

When I install the page as a PWA, start listening, and background the page, playback still stops at the end of each chapter. Only difference is that when I foreground the page again, the playback resumes automatically (instead of having to manually pause and then resume, like in the browser).

advplyr commented 6 months ago

I tested this in Brave browser as both a PWA and just accessing the website. In both cases it correctly switches to the next audio track while in the background with the screen off. In Brave I have the setting enabled "Background play" which is required to keep audio playing while the browser is in the background in general.

I'm not sure if there is anything we can do about this since it is likely browser/device specific. If anyone has more information on browsers they are testing with that can be helpful

thearrow commented 6 months ago

Ah - haven't tried Brave yet - I'll give it a try!

I've been testing with Orion 1.3.7 (15) (WebKit 8617.1.17.10.9) on iOS 17.2.1 with the "Enable Background Audio" turned on in Orion's settings.

matheusl02 commented 6 months ago

Same. Loving the software so far, but found this bug almost immediately. iOS Safari added to iPhone home page, at the end of each chapter it pauses - I note that the play button still appears to be “playing”, one has to pause and resume to get it working again.

matheusl02 commented 6 months ago

Just confirmed the bug occurs when using the brave browser on the same phone. software info: iOS 17.3.1 Brave: Version 1.62 (24.2.9.10)

I’ll try this on an android tablet with brave and chrome tomorrow

thearrow commented 6 months ago

Also can confirm the same behavior happens on Brave browser (with "Enable Background Audio" option enabled) 😢

iOS 17.3.1 Brave 1.62 (24.2.9.10)

When backgrounded, playback stops at the end of each audio track and only resumes when: foregrounded, press "pause", press "play".

My workaround for now has been only listening to books that are a single large m4b file 🤪

Nate-in-AK commented 5 months ago

I have not tried Brave yet, but Chrome and Safari both behave the same for me - playback stops at the end of each file.

Zeuzith commented 5 months ago

Can also attest to this issue, on an iPhone 15 running 17.3.1 using Safari, it will just stop playback at the end of every chapter. As soon as I open the webpage again, hit pause, then play, it will resume on the next chapter. Otherwise the software works seamlessly for me

thearrow commented 4 months ago

For others running into this issue, since the official iOS app beta is still full, I’ve been having good luck lately with: https://plappa.me/ as a native iOS client for audiobookshelf (not affiliated, just a happy user).

LazyBoBo commented 4 months ago

Same issue

Server:PVE -> Debian11 -> Audiobookshelf Client:iPhone 12 -> Safari , Chrome

Hope this issue to be fixed soon.

MBDamage commented 3 months ago

Can also attest to this issue, on an iPhone 15 running 17.3.1 using Safari, it will just stop playback at the end of every chapter. As soon as I open the webpage again, hit pause, then play, it will resume on the next chapter. Otherwise the software works seamlessly for me

I am also having this issue on an iPhone 15 Pro Max running 17.4.1.

Quite frustrating when you are doing things with wet or dirty hands to have to pause and un-pause to resume playback.

Let's hope someone smarter than I will give a fix soon enough :-)

advplyr commented 3 months ago

I tested this on iOS 17 and can reproduce the issue now.

This looks like a bug with iOS 17 and there is nothing we can do about it until it is fixed. I saw a lot of posts about audio-related issues with iOS 17. https://discussions.apple.com/thread/255418017

For future reference: I found this w3c draft for an audioSession api that could help with managing audio if it gets approved https://w3c.github.io/audio-session/ https://github.com/w3c/audio-session/blob/main/explainer.md

The-F4m3 commented 1 month ago

I actually have the same problem/behaviour on Android (12) with Firefox (128.0 (Build #2016030615))

Chrome works fine 🤷