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

fix: play video in background when screen is off #5546

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

arkibax
Copy link
Contributor

@arkibax arkibax commented Jan 24, 2024

This PR fixes issue #5141.
I took the approach to switch to audio player.

@Bnyro Bnyro added the discussion Should be discussed first label Jan 24, 2024
@Bnyro
Copy link
Member

Bnyro commented Jan 24, 2024

This also means that the normal player is no longer in sync, which should be discussed first or made optional.

@Pamilg8
Copy link
Contributor

Pamilg8 commented Jan 24, 2024

Lately the audio player is not working in the background .After opening the application, it may revert to the video player

@arkibax
Copy link
Contributor Author

arkibax commented Jan 26, 2024

When the screen is off and only if the video is playing, it switches to the audio player and continues from the last position of the video player. And when the user unlock's the device, he can switch back to the video player by tapping the button in the top right corner and it will continue from the last position of the audio player. (I suggest moving that button down to be easily reachable to the thumb.) Is that what you meant by sync or is it another thing?

Btw I found an error that only happens in home screen with this PR. When unlocking the screen and minimizing the player, video cards become invisible. I don't know how to fix but when switching between home tab and another tab, the home screen refreshes and shows the videos.

@arkibax arkibax marked this pull request as draft January 26, 2024 07:23
@M00NJ
Copy link

M00NJ commented Jan 28, 2024

Sounds like a pretty good idea imo. Though I think if it switches automatically to adio mode when the screen is turned off, it should also automatically switch back to video, when the device gets unlocked.

@Pamilg8
Copy link
Contributor

Pamilg8 commented Jan 28, 2024

Also, we click the home button and use other applications. It would be great if the audio player starts when you tap the home button. For continuous playback in the background, we need to press the audio + home buttons, then return to the application and press the button again to open the video player. Considering that this is difficult, it is better if we correct it.

Note: An option similar to opening a popup when you click the home button.

@IndusAryan
Copy link
Contributor

IndusAryan commented Jan 28, 2024

Note: An option similar to opening a popup when you click the home button.

another option??, you are right in first like , whenever app is in background whether screen off or on, it should switch to audio, but it'll be annoying if playback stops for sometime while changing the state or you already got the fix @arkibax ?

@Pamilg8
Copy link
Contributor

Pamilg8 commented Jan 28, 2024

I just expressed my opinion. The issue is tagged as a discussion

Note: An option similar to opening a popup when you click the home button.

another option??, you are right in first like , whenever app is in background whether screen off or on, it should switch to audio, but it'll be annoying if playback stops for sometime while changing the state or you already got the fix @arkibax ?

@IndusAryan
Copy link
Contributor

I just expressed my opinion. The issue is tagged as a discussion

lol, do i really sound that bad, i just asked if you want another option??, idc if it gets another option

@akano12
Copy link
Collaborator

akano12 commented Jan 28, 2024

We need an option called "Thanos mode" that when toggled would randomly delete half of the options available in the settings

@IndusAryan
Copy link
Contributor

We need an option called "Thanos mode" that when toggled would randomly delete half of the options available in the settings

i can add that if bnyro is serious about it.

second: i am also looking to remove many settings, but i dont know which setting to remove . team libretube should make a list of them in discussion.

@Pamilg8
Copy link
Contributor

Pamilg8 commented Jan 28, 2024

We need an option called "Thanos mode" that when toggled would randomly delete half of the options available in the settings

i can add that if bnyro is serious about it.

second: i am also looking to remove many settings, but i dont know which setting to remove . team libretube should make a list of them in discussion.

Why are you deleting? I didn't understand

@FireMasterK
Copy link
Member

I think the best behaviour would be to have it switch to the background player when the screen it turned off, and switch back to the video player, seeking to the background player's position when the device is unlocked.

@Pamilg8
Copy link
Contributor

Pamilg8 commented Jan 28, 2024

I think the best behaviour would be to have it switch to the background player when the screen it turned off, and switch back to the video player, seeking to the background player's position when the device is unlocked.

Yes, he did

@arkibax
Copy link
Contributor Author

arkibax commented Jan 29, 2024

@IndusAryan The playback stops for 1 or 2 seconds while switching. I think it's normal. But if somebody knows how to improve it feel free to review it.

This PR as of now, behaves as @M00NJ and @FireMasterK have explained.

Btw the bug in the home screen that i mentioned before is still happening.
I recommend testing this PR in case I missed something.

@0xrxL
Copy link

0xrxL commented May 14, 2024

From what I understood, this PR is stalled, due to some issue encountered by some users, including the lack of sync between audio and video (and viceversa) players during foreground/background switching.

I'm a dev...but not an Android dev (so I don't know how everything exactly works), but can't be eventually possible to run two player instances (video and audio together) and mute one of them depending by the app focus (foreground or background), to keep the sync and bypass every eventual bug caused by the solution in this PR?

@IndusAryan
Copy link
Contributor

From what I understood, this PR is stalled, due to some issue encountered by some users, including the lack of sync between audio and video (and viceversa) players during foreground/background switching.

I'm a dev...but not an Android dev (so I don't know how everything exactly works), but can't be eventually possible to run two player instances (video and audio together) and mute one of them depending by the app focus (foreground or background), to keep the sync and bypass every eventual bug caused by the solution in this PR?

together one will work, but it will require some higher memory as well as cause increased data usage, and syncing problem wont get solved there too, suppose the video loads but the audio track doesnt, and it will also increase some load on piped

@0xrxL
Copy link

0xrxL commented May 15, 2024

From what I understood, this PR is stalled, due to some issue encountered by some users, including the lack of sync between audio and video (and viceversa) players during foreground/background switching.
I'm a dev...but not an Android dev (so I don't know how everything exactly works), but can't be eventually possible to run two player instances (video and audio together) and mute one of them depending by the app focus (foreground or background), to keep the sync and bypass every eventual bug caused by the solution in this PR?

together one will work, but it will require some higher memory as well as cause increased data usage, and syncing problem wont get solved there too, suppose the video loads but the audio track doesnt, and it will also increase some load on piped

Not necessarily...

For example: video player could split audio and video tracks, and use its instance to buffer both for itself and audio player too.

Assuming that all this can be done, of course...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Should be discussed first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants