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
Videos stop playing when locked, because Libretube is put to sleep #5141
Comments
PRs welcome, as I already said I don't have interest in working on that since the audio only mode is good enough for the purpose of background playback. |
This issue is only about videos stopping after a few minutes, after you lock your device. So 7. |
Didn't you just fixed an audio player? |
Yes, but this issue is also about the video player audio was just a lot easier. |
@Pamilg8 do all of the issues you found already have github issues? |
I dont know.This PR can also solve background playback issues when exiting the app and browsing other apps.Also restarting the player when you return to the player while background playback is paused will fix the problem.Because, isn't it the same problem?🤔 |
For me the app crashes after a while when I lock the screen. This is the stacktrace shown after starting the app again. Im on android 14, app ver: 0.19.0 |
this could be fixed adding an exception on the battery settings so i doesn't get closed, and letting it linger under the radar. |
Happens with unrestricted battery usage too |
so i can't suggest anything, may helps giving libretube permissions through adb or root but i don't think that libretube can get advantage of root permissions so well i can't help with that your phone seems be very restrictive on that but in mine was fixed with that. |
I would recommend that if libretube is able to know if it has been send to the background or not, to convert the current session (video) to audio, it would probably save battery and mobile data |
On my device it just takes just 20 seconds until playback stops, if LibreTube is just in the background. There seems to be no effect if PiP is enabled or the screen is turned off. LibreTube 0.22.1 |
Steps to reproduce
Expected behavior
Video should continue playing.
Actual behavior
Video stops playing.
LibreTube version
0.19.0
Android version
Android 13
Other details
This is because Libretube needs to acquire a wakelock https://developer.android.com/training/scheduling/wakelock
in order for Android to not put Libretube to sleep after a few minutes.
Exoplayer can acquire this wakelock for us when it makes sense (i.e. video playing while the screen is off), so I thought I had a 10 line fix for this.
https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setWakeMode(int)
However when debugging afterwards I learned that exoplayer can only do this when it runs in a service like is already done in the audio player.
This should probably be implemented by extending the Offline and OnlinePlayerServices to also support video, and offloading all PlayerFragement player interactions to it.
The officially recommended solution is a mediasessionservice, however that would require a major refactor which is probably not something that can be easily done (I tried and failed miserably, but I also know little about android development).
I will send a PR to fix the audio player, it is less affected because it is already running as a foreground service, but will also be put to sleep after a longer interval or when Battery Saver is active.
I'm also trying to fix the video player but I'm not sure if I will succeed.
Acknowledgements
The text was updated successfully, but these errors were encountered: