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

Unexpected pauses when switching player type #5016

Closed
4 tasks done
alexlyzhov opened this issue Nov 27, 2020 · 35 comments · Fixed by #7349
Closed
4 tasks done

Unexpected pauses when switching player type #5016

alexlyzhov opened this issue Nov 27, 2020 · 35 comments · Fixed by #7349
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)

Comments

@alexlyzhov
Copy link

alexlyzhov commented Nov 27, 2020

Checklist

Steps to reproduce the bug

  1. Start some video in NewPipe
  2. Minimize NewPipe by pressing home or opening Android recent applications drawer
  3. Enter NewPipe again

Actual behaviour

When I minimize the app, the audio stops playing for like 100-600ms and then resumes. It's pretty annoying.
When I reenter the app, the same thing happens.

Expected behavior

No pauses in the audio are expected.

Screenshots/Screen recordings

Recording on youtube

Logs

Device info

  • Android version/Custom ROM version: latest Android 10
  • Device model: Asus ZenFone 5Z
@alexlyzhov alexlyzhov added the bug Issue is related to a bug label Nov 27, 2020
@alexlyzhov
Copy link
Author

It's certainly not connected to my internet speeds, all the other youtube apps never have this issue

@alexlyzhov
Copy link
Author

All the battery-saving power management options are disabled on my phone

@vkay94
Copy link
Contributor

vkay94 commented Nov 27, 2020

This is expected because the player type is changed. The player is destroyed and recreated again. You should have noticed it too when you minimized it. It's just longer during entering because the details screen takes more time to create than the background player for example.

So it's basically no bug but designed like that.

@alexlyzhov
Copy link
Author

alexlyzhov commented Nov 27, 2020

Is it a good design element? Would it be difficult to make the playback persistent like in other youtube apps?

@vkay94
Copy link
Contributor

vkay94 commented Nov 27, 2020

Hmm, I checked it. I though if you leave the app while the details are visible the player changes to the background player but it isn't. So you're right, there is basically no necessary to reload it.

@Stypox Is it always needed to re-assign the PlaybackManager in this specific case when the play queue entries are equal?
onFragmentStopped / Resume case -> useVideoSource -> reload

@avently
Copy link
Contributor

avently commented Nov 29, 2020

@vkay94 the pause is just a process that reload the stream with video enabled or disabled based on current situation (the app in background - video disabled, in foreground - video enabled). So reload triggers track selection.

@ghost
Copy link

ghost commented Dec 25, 2020

@vkay94 the pause is just a process that reload the stream with video enabled or disabled based on current situation (the app in background - video disabled, in foreground - video enabled). So reload triggers track selection.

This behaviour doesn't happen on Vanced.

@Coderdude112
Copy link

Is there any update to this? I am still having this issue a lot.

@Stypox Stypox closed this as completed Mar 19, 2021
@Stypox Stypox reopened this Mar 19, 2021
@Stypox
Copy link
Member

Stypox commented Mar 19, 2021

This behaviour doesn't happen on Vanced.

@Oizaro probably vanced just keeps playing the video in the background, instead of switching to audio. I don't know if there is any way to improve this.

@Coderdude112
Copy link

What are the draw backs of this? If the video keeps playing without pauses isn't that good?

Idk how switching to a different player works but, would there be a way to implement something like using the same video player for the rest of the playing video and then switching to another video player when the video is done? That way the pause for the switch is hidden a little better and less obnoxious.

@Stypox
Copy link
Member

Stypox commented Mar 19, 2021

@Coderdude112 the drawbacks are increased battery consumption and data usage, since the video would still be loaded alongside audio

@Coderdude112
Copy link

Honestly how much would it use tho. I used vanced for a long time without significant battery loss...
Even adding it as an option would be nice

@Stypox
Copy link
Member

Stypox commented Mar 19, 2021

Then maybe Vanced is able to change the playing stream seamlessly, but NewPipe is not and none of us has any idea how that could be achieved

@Coderdude112
Copy link

Wouldn't my previous suggestion work tho? Also how did vanced edit the original YT app

@avently
Copy link
Contributor

avently commented Mar 19, 2021

YouTube app uses another type of video streams unsupported by newpipe as far as i know. it allows to disable video without stopping audio

@triallax triallax changed the title Unexpected pauses Unexpected pauses when switching player type Apr 6, 2021
@Logarithmus
Copy link

YouTube app uses another type of video streams unsupported by newpipe as far as i know. it allows to disable video without stopping audio

What another type? Do you mean HLS or separated video & audio?

@Logarithmus
Copy link

Logarithmus commented Jul 26, 2021

This issue is super annoying BTW. I think that we can just use 2 separate players for video and audio and when going to background mode just stop the video player. When going to picture-in-picture mode, we should continue playing the old video stream downscaled. And then asynchronously fetch the stream with smaller resolution and smoothly transition to it. YouTube Vanced and official app do that, and if NewPipe would support that too, then it would be the best YouTube app ever.

@Coderdude112
Copy link

This sounds great! I would really love to see this implemented.

@ghost
Copy link

ghost commented Aug 11, 2021

+1 please it's been months I'm going insane.

@Darkmaster006
Copy link

This also happens when I click in 'Settings' and when I go back to the video from 'Settings' (this all inside the app).
EDIT1: This also happens if you press 'Downloads' or 'About'.
EDIT2: Very weird, if I choose 'open in pop-up mode' and I don't give it any permission to open it in pop-up mode, it will open it in background mode and there'll be no freezing. Any ideas?
EDIT3: This also occurs when I turn on and off the screen, even with the 'trick' of EDIT2. This also happens if the screen turns off by itself.

Hope this can be fixed.

@Logarithmus
Copy link

@Darkmaster006 I want to fix it so much, I know a bit of Kotlin & Java Android development, but unfortunately won't have free time for that any time soon ☹️

@opusforlife2
Copy link
Collaborator

See #2863 for earlier discussion around this. As stated there, this will have to wait until DASH is implemented in Newpipe. You are welcome to help test the DASH PR (#6537) for bugs so that it can be merged faster. :)

There are 2 scenarios here: 1st is navigating within the app, and the 2nd is going outside the app (even phone locking counts as this). Possible solutions:

  1. Video stream keeps playing in the background when user opens menus inside Newpipe, because in most cases, they will shortly exit the menu. Toast: "Video still playing in background. Switch to audio to save data." -> user can choose to switch to audio manually before browsing menus in the app.
  2. Going outside the app:
  • When the user switches away from the app, the video stream should keep playing in the background until the popup/audio stream(s) is/are loaded in another player instance, then seamlessly hand off playback and pause the first player instance. (Taking the 2 player instances idea from what avently said in the last paragraph of Seamless / smooth transition when switching players #2863 (comment).)
  • When the user switches back to the app, the paused video stream can jump to the timestamp the audio/popup stream is at and resume. I don't know if there is a way to do this step seamlessly.
  • If user quickly switches back to Newpipe before 2nd player has fully loaded, just keep playing the video stream and close the 2nd player instance.

Seamless switching may require the video resolution of the main/popup players to be the same.

@ghost
Copy link

ghost commented Sep 17, 2021

I would just like to add that this happens both ways. Leaving a stream with video and entering it.

Ok so if we fetch audio and video at the same time then suddenly we only need audio then we can drop the video stream but the audio should continue streaming seamlessly. There should not be a stutter in that case.

If we enter the video stream then it would be understandable because suddenly we need to fetch the video stream.

I think there should be a toggle in settings that would allow fetching a video stream in the background thus "wasting" more data. But the switch would be seamless. People - who actually know how to do this - should check what exactly happens when switching. Btw this could also be tied into the mobile internet toggle so it does not waste data.

@peepo5
Copy link

peepo5 commented Oct 14, 2021

This is the nitpicky problem with newpipe I have. I like to play soundcloud music, but when switching between other apps, it jumps which is annoying. I do not understand why there is a jump as I don't see a reason to switch player type for audio-only content.

@Coderdude112
Copy link

Coderdude112 commented Oct 21, 2021

So, according to @Stypox we don't currently have an idea of how to implement this functionality.

After a little searching online i found this doc page from Google, and while avoiding their products is kinda the reason behind NewPipe, they do give full examples for how to implement seamless transition between the full-screen video player and a PiP video player and back. Found here: https://developer.android.com/guide/topics/ui/picture-in-picture

Would it be possible to implement this in addition to the concept of dropping the video stream, but keeping the audio stream alive when the user wants to go from video to audio. This would reduce the need for the pause to only when the user is going from audio only to audio and video.

@peepo5
Copy link

peepo5 commented Oct 21, 2021

is it a special type of audio player? most music apps have this feature.

@opusforlife2
Copy link
Collaborator

I like to play soundcloud music, but when switching between other apps, it jumps which is annoying.

@peepopoggers You're playing it in the main player. If you play it in the background, then you won't have this issue. Background mode should be the default for audio-only services like Soundclound and Bandcamp, but for that we'll need someone to come forward and code the changes.

@peepo5
Copy link

peepo5 commented Oct 23, 2021

I do play it in the background and it still skips while switching focus

@opusforlife2
Copy link
Collaborator

I do play it in the background and it still skips while switching focus

@peepopoggers Just tried it and there's no skip. Do you have a permanent notification while it is playing in the background?

@peepo5
Copy link

peepo5 commented Oct 23, 2021

I do but it skips. It shows a little time glass icon when switching for a fourth of a second before unpausing again.
Using calyxos.

@opusforlife2
Copy link
Collaborator

I do but it skips. It shows a little time glass icon when switching for a fourth of a second before unpausing again.
Using calyxos.

@peepopoggers That only happens when you switch player type. Are you absolutely sure you're not tapping the thumbnail and opening the main player? Even if it has the headphone icon, it's not actually playing in the background. The icon is misleading and needs to be changed.

Does it happen to you on Youtube as well? Playing in background, switching to another app, and noticing a pause?

@peepo5
Copy link

peepo5 commented Oct 23, 2021

@opusforlife2 Alright that seems to work, I thought the headphone icon meant background. That sure is confusing and I think it needs to be changed.

@ghost
Copy link

ghost commented Nov 12, 2021

@opusforlife2 mpv does this as well. Maybe NP uses the same player as mpv and the problem is with that instead?

@opusforlife2
Copy link
Collaborator

@IHateTheProgrammingClass Why speculate on all that when you have a perfectly good PR right above you waiting to be tested? Check it out, it's awesome!

@ghost

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)
Projects
None yet
10 participants