OdyseeTeam / odysee-ios

The Odysee iOS app with wallet functionality.
MIT License
67 stars 22 forks source link

Don't enter PiP for a fraction of a second when backgrounded #338

Closed anohren closed 2 years ago

anohren commented 2 years ago

When backgrounding the app with the home button while playing a video (not in mini player) the video transitions to PiP for just a moment, and then PiP disappears. This has multiple problems:

  1. It doesn't work as PiP, obviously, while still raising expectations on the app that PiP is intended to be supported.

  2. It has the side effect of making the video keep playing when moving to the background, weirdly making the app behave opposite to the behavior described in #226 since the mini player still auto pauses when app is backgrounded. It wouldn't necessarily be that bad, if only there were some consistency so that the behavior at least is easily predictable.

  3. Sometimes the PiP window isn't dismissed immediately, while at the same time showing/playing no content. PiP is now stuck indefinitely, until you dismiss it manually.

tzarebczan commented 2 years ago

Thank you for filing this detailed report! Definitely need to focus on this experience on IOS, we'll try to get it prioritized!

ktprograms commented 2 years ago

I can't reproduce this on my iPad 9th gen or the simulators. What device and OS version are you using?

anohren commented 2 years ago

iOS 15.5 iPhone 8

ktprograms commented 2 years ago

I've taken a look at this, and it turns out that the iOS simulator doesn't support PiP, and there was a variable not set correctly for it to work on iPad.

I can reproduce it now, and it's caused by the player being disconnected once the scene enters the background, which causes PiP to stop. Unfortunately, the events received for entering the background vs entering PiP are the same, so we will either need to choose if PiP or background playback is desired, or alternatively there could be an option in Settings.

@tzarebczan @anohren What do you think?

anohren commented 2 years ago

I think that since PiP doesn't work (for me at least?) after transitioning to background, even when entered manually with the button, that the first question is whether PiP is intended to work already and whether that should be fixed first. Otherwise it seems natural to not choose PiP since it's not working properly, and defer the decision of how to choose between the two to a later date.

PiP seems to work only as long as the app is in the foreground, which is pretty much the same as not at all, since as soon as you navigate away you end up with both PiP and the mini player...

ktprograms commented 2 years ago

The fix to keep PiP open is not disconnecting the player when going to background, which I will implement.

The reason why I'm asking if there should be a setting is, if the player is not disconnected, but PiP isn't used, then playback will stop, so background audio won't work.

anohren commented 2 years ago

Oh, if that's all it takes to make PiP work then that's great.

Ok, if PiP can be made to work reliably then it probably has to be an option. All situations in the app are somewhat ambiguous: even when watching in the mini player you can't really say for sure whether the picture is desired, because the mini player is mandatory.

If it were to be intelligent I'd say it would be something like this:

But a reliable PiP in-app would also potentially open up to get rid of the mini player entirely (?)

tzarebczan commented 2 years ago

Do other apps like YouTube behave the same way?

anohren commented 2 years ago

Great, Safari deleted my reply, as if throwing away all my tabs every single day weren't enough. Safari on iOS 15.5 is such a disaster...

In short: I don't use the YouTube app. Almost no app seems to use PiP though, not even Files. A shame. But Safari transitions automatically only in fullscreen -- not while watching embedded in the page. The Apple Developer app does something similar as I recall, but now that I can't trust Safari at all I can't switch app to confirm anything while typing.

Edit: The developer app transitions automatically also when not in full screen, similar to my take of it above. The logic should apply here too; the app's focus is watching video so we can assume the video is the focus of the page even when not in fullscreen.

I can think of pretty much no other app that actually supports PiP, that I use. Pure media players like VLC sure don't (maybe not the best example of an app that cares about extensive integration though).