Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background Audio Playback #19

Open
anthonylavado opened this issue Nov 21, 2019 · 65 comments
Open

Background Audio Playback #19

anthonylavado opened this issue Nov 21, 2019 · 65 comments
Labels
enhancement Improve existing functionality or small fixes

Comments

@anthonylavado
Copy link
Member

According to some pages in Expo's documentation, this isn't supported, yet on other pages, it says it is?

Here in limitations it says no:
https://docs.expo.io/versions/latest/introduction/why-not-expo/#limitations-of-the-managed-workflow

But here it says we can do it with the right app.json entry and object:
https://docs.expo.io/versions/latest/sdk/audio/#audiosetaudiomodeasyncmode

We should see what we can do to get this working.

@anthonylavado anthonylavado added the enhancement Improve existing functionality or small fixes label Nov 21, 2019
@Camotoy
Copy link

Camotoy commented Nov 24, 2019

Since we're SO CLOSE to getting a near-perfect Jellyfin audio experience I went ahead and saw what I could do with this. I'm familiar with programming but haven't touched any form of JavaScript since an HTML class.
The Audio.setAudioModeAsync() function seems to be what we need, but I tried just putting it into App.js with no luck. And it's the function being missed entirely - I tried disabling the function's playsInSilentModeIOS parameter and sound still played on my iOS device on silent. My current theory is that the code only affects any local code, and this repo gets most of the UI from the web. Or, the code to show the web UI in this repository is somewhere else.
I'm going to keep looking and testing.

@anthonylavado
Copy link
Member Author

If I'm not mistaken, the Web UI in this is literally the interface from the server. That is to say, it is more like a special browser itself. Could be wrong. Paging @thornbill.

@samuel9554
Copy link

Hey guys on Ipad 5th Gen running iOS 12.4.1 I don't have this issue closing the screen, changing apps the music will continue to play. But the next song in the play list will not start. Hope it help.

@thornbill
Copy link
Member

I believe this is caused by the js execution in the webview being stopped when in the background. I saw the same behavior in iOS 12 where it would complete the current song, but not continue to the next song. It seems that iOS 13 is much more aggressive with killing background tasks and so it does not even complete playing the current song.

I think the best solution is to use the NativeShell interface in web to inject a plugin to play audio via a native element. Hopefully that will resolve this issue. 🤞

@RealDyllon
Copy link

It’s a known issue with expo: expo/expo#5472

When an expo app starts playing audio, then moves to the background, the audio will continue till the end. However, the next audio file won’t start playing (on iOS).

I think react native supports background audio playback, but that would require ejecting the entire project.

Looks like expo is working on a fix, no ETA: https://expo.canny.io/feature-requests/p/audio-playback-in-background

@dannymichel
Copy link

Is the current iPhone app available in the app store outside of expo still considered the expo app? Is that why background playback isn't supported in that version either?

@thornbill
Copy link
Member

@dannymichel yes it’s the same app.

@TwentyH
Copy link

TwentyH commented Mar 20, 2020

Expo issue linked above doesn’t look like it will ever be fixed. Is there an alternative?

@anthonylavado
Copy link
Member Author

Expo issue linked above doesn’t look like it will ever be fixed. Is there an alternative?

@TwentyH Yes? Kind of. We could eject from Expo and see about starting to re-implement this app as a “closer” to react-native project, but then that means that to work and build the iOS version, you’d have to use a Mac for development (right now that’s not required). There’s a variety of options we’re weighing internally.

@TwentyH
Copy link

TwentyH commented Mar 22, 2020

Expo issue linked above doesn’t look like it will ever be fixed. Is there an alternative?

@TwentyH Yes? Kind of. We could eject from Expo and see about starting to re-implement this app as a “closer” to react-native project, but then that means that to work and build the iOS version, you’d have to use a Mac for development (right now that’s not required). There’s a variety of options we’re weighing internally.

Maybe I am not operating it properly, but the iOS app is unusable as it is today, anyway, pausing every time the screen locks. Wouldn’t making it a native app work around this problem, even if it is used only for streaming (UPnP or DLNA), and keep the current web view for managing the playlist?

@anthonylavado
Copy link
Member Author

@TwentyH It works in limited use cases. People were clamouring for an app for iOS, but we don't have any Swift or Objective-C developers on the team. This is the best compromise we could come up with in this time.

There are other options that we are continuing to discuss internally, because we do want this experience to improve.

@kruzader
Copy link

@anthonylavado I am an iOS developer and would be interested in developing the native app as a regular user of Jellyfin. In case we could talk about it.

@dkanada
Copy link
Member

dkanada commented Mar 28, 2020

@kruzader we can definitely talk about it 😄 since we have no extremely active iOS developers you can literally do whatever you want and if it's better than the current solution we can release it officially and start maintaining it. There is an old Swift API client in the organization you can start with if that helps at all, but it might need a few changes to get working on the latest releases.

@dkanada
Copy link
Member

dkanada commented Mar 28, 2020

I found the client here and it looks like we never made any changes, but it should be 99% functional with the current server. I will say that based on our work with other API clients you will probably want to make a lot of changes.

@drazil100
Copy link

Was checking in on this since being able to use the jellyfin app as my primary music player is very important to me. Thought I’d also share what my current temporary solution is while I wait for background play.

After hours of scouring the App Store and google for apps that could possibly interface with my Jellyfin server for specifically music I ended up finding foobar2000. It’s not my favorite music player I have used but it interfaces really well with UPnP and allows me to download every music album on my jellyfin server at once with album art and uses your music’s metadata to sort songs (you legit wouldn’t believe how hard it was to find an app that did all that in one package)

It’s really not an ideal solution because foobar2000’s playlists are based on file locations and therefor updating your media in anyway requires songs maintain the same file name and location on your device.

I would REALLY like to use the jellyfin app as my primary music player and will be ditching foobar2000 the moment jellyfin is capable of being my primary music player. Just thought I’d share my temp solution for anyone in need of a more immediate solution.

Keep up the great work guys.

@27md
Copy link

27md commented Apr 29, 2020

thanks @drazil100 this works great for me until background playback is fixed

@anthonylavado
Copy link
Member Author

Possibly a fix in #82, which would require testing.

@HarryPaulo
Copy link

@anthonylavado
I tried this change #82 with "expo-keep-awake" but it didn't work.
continued to stop sound in the background with 2 Google pixel 2 and sansung A30 phones.

@anthonylavado
Copy link
Member Author

@HarryPaulo Thank you for testing. The Android side of this app is... less tested (I'll leave that more to @thornbill). We do have an official Android app, as well as a few other Android things in development for music playback.

@thornbill
Copy link
Member

I still need to test that change. I believe it only keeps the screen from automatically locking when the app is in the foreground. It’s not a real fix for playing while in the background, but it seems like a good first step. I don’t think we will get full background playback support until we implement a native player in the app.

@drazil100
Copy link

I agree its a good first step and I have often wondered about requesting this as a temporary measure. But really I just need background playback so I just didn't suggest it.

Not having my phone fall asleep on me when I am listening to music would actually make this app usable for music at all though. At best right now I can only listen to 2 and a half minutes of music without interacting with my phone before it locks and stops background playback.

@HarryPaulo
Copy link

I have a simple radio application, I am looking for a fix for my problem with the background application.

maybe this can help other people, I will test this alternative, in my case it can solve, but I will stop using the expo-av:

https://dev.to/chafikgharbi/a-trick-to-play-sound-on-screen-lock-or-background-in-react-native-and-expo-32ml

@thornbill
Copy link
Member

Relevant upstream issue: https://bugs.webkit.org/show_bug.cgi?id=203293

@thornbill
Copy link
Member

There is something of a workaround for iOS 13.5. Once playback stops, you can resume playback by pressing the play button twice on the lock screen. It seems to continue playing without stopping while in the background after that. The UI does not update correctly to reflect the current state however.

@leocaseiro
Copy link

leocaseiro commented Jul 3, 2021 via email

@thornbill
Copy link
Member

Well it seems like this is once again an issue in iOS 15. I recommend using an alternative such as Finamp in the meantime.

@thornbill thornbill reopened this Sep 24, 2021
@drazil100
Copy link

Finamp is great! If you use Jellyfin for music you should probably just use Finamp period.

@jonatasbaldin
Copy link

I still suffer from the same problem :(

@ghost
Copy link

ghost commented Jul 17, 2022

Finamp is great! If you use Jellyfin for music you should probably just use Finamp period.

@drazil100
Would do this but i would prefer only using one app as i watch movies and tv...

Good news! I can say that for the most part excluding this audio playback issue the app seems to be set for iOS 16 (as of the first beta) as i have not experienced any bugs

Edit: Never mind no external playback controls show for videos ( and of course audio) on the lock/notification screen

@nodecentral
Copy link

nodecentral commented Feb 3, 2023

Just adding to this thread to say this still occurs on my iOS device , and it’s made more annoying as I use Jellyfin mainly at the gym and have to switch between apps. Would really love to see this fixed somehow so I can have uninterrupted music..

FYI - when I start the Jellyfin app up the first time it seems to work fine and is ok running in the background , but if for any reason you interact with it again and bounce between apps it risks losing that ability and will get stopped by the simplest of things e.g a pop up notification .

@janiversen
Copy link

iPad Air with iPadOS v17.1.2, newest Jellyfin-mobile from Apple Store installed, newest released jellyfin server...

but the player still stops on screen lock or when it goes in background.

Any idea when this will be solved ?

@MININT2
Copy link

MININT2 commented Jan 19, 2024

i am here to say that this is still an issue 4 years later, i'm on ios and this is one of the most annoying things, along with the fact that the next track never plays unless i'm looking at the app directly while driving.
i've come to realize that this will never be fixed or worked on considering how long it's been, it is 2024.

@janiversen
Copy link

Do you use an alternate app on iOS ?

It is a very disturbing error, but I think you are right, there are no developers interested in fixing it.

I have been looking at swiftfin, which works quite nicely for video....I am looking at extending it to support audio as well, together with jukebox functionality (I have a RPI4, and I am tired of running airplay, when it could connect directly to Jellyfin).

@zsarosi
Copy link

zsarosi commented Feb 13, 2024

For me it was working till the second last iOS update (currently 17.3.1), so it was working with 17.2 or something. Some two years ago I had the same problem, but then it was fixed till now when it does not work again.

@gnattu
Copy link
Member

gnattu commented Apr 5, 2024

For a music-centric use case, please check out AmpFin, a native implementation of the Jellyfin music player on iOS.

The problem with this Expo implementation is not trivial to resolve because simply offloading the audio playback to the system will not be sufficient. The playback queue also needs to be offloaded, and we cannot reliably use JavaScript in the WebView to manage the music playback queue because the execution of the JS inside a webview may be paused by the OS at any time in the background. A more native implementation is required to have a reliable background playback functionality.

@drazil100
Copy link

I have been using finamp ever since it came out and I have been liking it. Finamp seems to have a good amount of support behind it too. I might give AmpFin a try and see how I like it but I am very happy with Finamp.

@iChristGit
Copy link

I have been using finamp ever since it came out and I have been liking it. Finamp seems to have a good amount of support behind it too. I might give AmpFin a try and see how I like it but I am very happy with Finamp.

As of iOS 17.5.1 the issue has not fixed with native Jellyfin app, thanks for recommending this app, works great and gives a premium apple music like UI vibe.

@sazarkin
Copy link

Is there any recommendations/workaround to listen audiobooks?

@nodecentral
Copy link

So just to confirm, on IOS the only current way (workaround) for someone to preserve their music continues to play in the background if you need to bounce between apps etc. is to use a separate Jellyfin compatible music player?

Recommended players are things like finamp, or ampfin etc.

This will be the approach until such a point that the Jellyfin app itself is updated to support it

@drazil100
Copy link

@nodecentral This is correct. But honestly I enjoy finamp so much that even IF the Jellyfin iOS app started supporting background playback I wouldn't switch back. At this point it's less of a workaround and is more just a better experience than Jellyfin app could ever be for music playback.

That's not me disrespecting the official Jellyfin app either. 3rd party devs have just had enough time at this point to focus on developing music player specific features that would be extremely difficult if not impossible for the official app to support, or features that would make no sense outside of the context of music.

For example one of the features in the finamp beta is that it will remember your play queue and let you resume whatever album, shuffled playlist, or whatever else you were listening to last even if you fully close and reopen the app.

@TheColin21

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing functionality or small fixes
Projects
Status: Needs Investigation
Development

No branches or pull requests