Open anthonylavado opened 5 years ago
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.
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.
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.
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. :crossed_fingers:
It’s a known issue with expo: https://github.com/expo/expo/issues/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
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?
@dannymichel yes it’s the same app.
Expo issue linked above doesn’t look like it will ever be fixed. Is there an alternative?
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.
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?
@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.
@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.
@kruzader we can definitely talk about it :smile: 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.
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.
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.
thanks @drazil100 this works great for me until background playback is fixed
Possibly a fix in #82, which would require testing.
@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.
@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.
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.
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.
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:
Relevant upstream issue: https://bugs.webkit.org/show_bug.cgi?id=203293
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.
Just tried it and waiting for it to pause and resuming from the lock screen does in fact work. Would be nice if I didn't have to wait for it to pause itself before I can resume it (pausing and unpausing immediately does not work). Would be nicer still if it actually legitimately supported background audio playback. But I'm just about fed up with trying to sync my music library to my iPhone so maybe this is good enough until an actual fix is developed.
Good luck to whoever eventually goes to tackle this issue.
Hey guys,
As background audio support in Expo appears to be far out and I happened to have some spare time on my hands, I opted for creating a bare React Native app that specifically targets audio streaming, with full support for background audio and AirPlay. Find it here: leinelissen/jellyfin-audio-player. It's mostly optimised for iOS, but I figure it should work well on Android as well.
If anyone has a spare developer license lying around, I can maybe setup Testflight so trying it out is a bit easier.
Cheers!
@leinelissen I opened an issue about it on your repository, and while we don't have a spare license lying around, we do have a license...
A thought just occurred to me. Since getting the process to keep playing in the background is so difficult right now would it be possible to instead get it to stop immediately in a way that the workaround mentioned above can be done immediately instead of having to wait a minute for the music to stop?
Ideally of course having music just able to play in the background is the long term goal but if that’s too far in the future a short term fix might help ease the pain.
Hey guys,
As background audio support in Expo appears to be far out and I happened to have some spare time on my hands, I opted for creating a bare React Native app that specifically targets audio streaming, with full support for background audio and AirPlay. Find it here: leinelissen/jellyfin-audio-player. It's mostly optimised for iOS, but I figure it should work well on Android as well.
If anyone has a spare developer license lying around, I can maybe setup Testflight so trying it out is a bit easier.
Cheers!
I'm trying it right now, the music not playing in the background is a huge problem for this kind of audio streaming service... Looking to move away from Google play music, so Jellyfin seems like the perfect match - except this ...
Same here @karanbole. I originally looked into jellyfin to get away from GPM's buggy as heck iOS app. Unfortunately jellyfin right now is video streaming first and music streaming second as far as what people seem to be focused on developing. I am still very hopeful that some of the issues like the lack of background audio playback will get fixed though especially if that music only app is any good and gets an official release.
In the meantime I have been using foobar2000 to download music from my jellyfin server off UPnP. It's not a perfect solution but it works for my needs.
@drazil100 @karanbole If you check out the repository I mentioned you'll find there are IPA and APK packages for iOS and Android respectively. I am working on getting the app on TestFlight at least in the near future. Background audio playback is fully working. I would love to get your feedback on what it takes to create an experience you can daily drive, so that we can make audio streaming a solid part of the Jellyfin ecosystem. Feel free to try it out and leave an issue at the repository 😉
@drazil100 @karanbole If you check out the repository I mentioned you'll find there are IPA and APK packages for iOS and Android respectively. I am working on getting the app on TestFlight at least in the near future. Background audio playback is fully working. I would love to get your feedback on what it takes to create an experience you can daily drive, so that we can make audio streaming a solid part of the Jellyfin ecosystem. Feel free to try it out and leave an issue at the repository 😉
The app is now available on TestFlight for all who want to check it out: https://testflight.apple.com/join/cf2AMDpx 🎉
Great ! Installing it right now and will keep you posted 👍
@leinelissen Great job. The first tests went pretty smooth.
Is this still working? I had latest iOS and it seems not working on my iPhone. Is there any other media server alternative you guys recommend that iPhone client doesn't have this limitation? Thanks.
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.
Looks like from my limited testing tonight(played 3 full songs with screen locked), this issue has been fixed with iOS 14. I believe there was an upstream bug that was finally fully fixed with iOS14.
I'd recommend anyone able to upgrade to iOS14 to do so and test.
I'll have to give it a try! I hadn't even considered iOS 14 may fix it. Will report back after I test.
Ok so it is confirmed to not put the music stream to sleep on iOS 14. I have no access to the next and back buttons to change songs from outside the app however. That may be better as it's own issue though.
I can confirm the same behaviour. I'll leave it to @Thornbill to decide if this should be closed or not. Related comments are in that new issue.
upgraded and confirm it is working now.
work well on IOS-14 with latest Jellyfin version :) Thanks.
Closing this since the issue was resolved in iOS 14! 🎉
Hey @thornbill, is it possible to keep playing in background without the need to press "play" on lock-screen?
This feature is available in other video players such as VLC, and youtube premium.
Ok, I was able to get the background music to work for mp3 only on IOS, but it doesn't work on videos. Is it possible to add the same feature to a video (mp4, avi, etc..)?
When I lock a screen to a playing video, it pauses automatically, and I have to press play after that. The same goes if I swap apps, from Jellyfin to another app.
@leocaseiro I would have to look into it a bit more. It may be possible to set some flags to enable background video playback.
Hi @thornbill Thank you for your reply.
It's a real and known issue with expo-av, I raised a ticket and someone raised a PR in their repo. https://github.com/expo/expo/pull/12950
Great news! Expo just released a fix for the iOS video, now audio won't stop while video is in background.
https://github.com/expo/expo/pull/12950
I believe we need to upgrade to expo@4.2 to address this fix.
I'll try raise a PR for that, hope that won't have any breaking changes.
Nice! It is a bit of a process to update Expo. There are normally some migrations that need to be done for their releases. We are a few versions behind at this point so we will need to incrementally update to 40, then 41, and finally 42 following the recommendations in their release notes listed here.
Hi, I noticed that we can only update expo-av. The only drawback is that no longer supports iOS 10.
On Sat, 3 Jul 2021 at 1:09 pm, Bill Thornton @.***> wrote:
Nice! It is a bit of a process to update Expo. There are normally some migrations that need to be done for their releases. We are a few versions behind at this point so we will need to incrementally update to 40, then 41, and finally 42 following the recommendations in their release notes listed here https://github.com/jellyfin/jellyfin-expo/issues/219.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jellyfin/jellyfin-expo/issues/19#issuecomment-873335044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHFQJVPP3FIVXRRZEBIZL3TVZ5QJANCNFSM4JP3PKPQ .
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.