TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.55k stars 3.07k forks source link

[Android 8.0+] Add Android Picture in Picture support #2223

Open arunkcx opened 5 years ago

arunkcx commented 5 years ago

With the latest Android Q beta release, apps installed outside the play store have their Screen Overlay permission revoked in 30 seconds after enabling them. This is to track down and stop shady apk apps which abuse the screen overlay option and get users to click on things they didn't mean to, malware etc. More info in article below

https://www.androidpolice.com/2019/03/16/android-q-steps-up-the-fight-up-against-overlay-based-malware/

Problem is, NewPipe uses screen overlay for the popup and having to re-enable the permission every time a new popup video is being played... The ideal solution is to switch to the native PIP mode from Oreo API 26 and up, and leave the existing floating player code for Android Nougat and older.

https://developer.android.com/guide/topics/ui/picture-in-picture

Slowly as dev time goes on and more users move to Oreo and higher, the floating player method can switch to PIP completely.

theScrabi commented 5 years ago

Sad. Google is 100% annoying recently. So yea I guess we need pip now. We might also need help for that.

PeterHindes commented 4 years ago

No issue so far with the emulator. Tested by rebooting the emulator.

My AVD Config

B0pol commented 3 years ago

It seems like it was a bug, or a test with Android Q beta that has been reverted ( https://teddit.net/r/Android/comments/b5y1yz/allow_display_over_other_apps_and_other/ ).

The issue stays open because we should still implement Android's picture in picture.

opusforlife2 commented 3 years ago

@B0pol Does PiP lack or implement any features different from NewPipe's popup player?

B0pol commented 3 years ago

It lacks resizability on Android 10- (new feature in android 11) and I think we can add buttons (speed, subtitles) but I'm not sure. Users are used to Android PiP because other apps. We won't need to maintain it because Android will.

But then because it does not bring a lot of benefits, it does not have a high priority indeed.

opusforlife2 commented 3 years ago

Then we should probably wait until the minimum Google-supported Android version is 11, which will take 3 years, I think.

PacoBell commented 3 years ago

With the advent of Android 12, overlays have become restrictive to the point that activating them essentially renders all other OS interaction useless.

https://developer.android.com/about/versions/12/behavior-changes-all#untrusted-touch-events

The Android 12 PiP now supports resizing and even includes features NewPipe currently does not support: "stashing" and smooth transitioning when exiting PiP. And, speaking of which, the gesture to dismiss PiP is now effortless. You don't have to carefully target a specific touch point, you just fling the window down vaguely toward the bottom and Android gets the gist and closes it for you.

The time to move on to PiP is now (at least for Android 12+).

PacoBell commented 3 years ago

Alternatively, it seems one could use ADB as a workaround on an individual basis:

adb shell am compat disable BLOCK_UNTRUSTED_TOUCHES com.example.app

schnatzi commented 3 years ago

I would take on this issue as a direct victim of the changes Google introduced 😅

But first I would like to address the issue of compatibility with the existing popup. In my opinion the best solutions would be to either make the PiP player dependent on the Android version (Starting with the first that needs it -> 12.0+) or as already mentioned by @dbenjaminmiller on #6770 as an option in the player settings. Personally I prefer the first one, as it is more user friendly, but with the ability to switch back to the old popup player.

Any opinions on this?

EliteMasterEric commented 2 years ago

Any opinions on this?

I agree here. The option in the menu should be a drop-down between:

Providing an option is good in case one has problems, and the overlay version should stay in place in the event that either Google makes a fix (such as adding a permission to allow overlay touches) or the user is on a previous version of Android.

Please let us know about your progress as work continues.

grayum commented 2 years ago

Agree with @MasterEric drop-down menu. Defaulting on auto but being able to overrule it would be great for everyones needs.

triallax commented 2 years ago

@schnatzi assigned. :)

opusforlife2 commented 2 years ago

@schnatzi Any progress with this?

AudricV commented 2 years ago

Because of the lack of response of @schnatzi, someone else can now work on this issue.

Free feel to ask for help if you have difficulties to implement this feature here and on our IRC channel.

SameenAhnaf commented 2 years ago

@B0pol This issue should be closed as #6770 has way more discussion. Separate issues should not be required to open for the same thing.

schnatzi commented 2 years ago

@TiA4f8R: Sorry, I missed the notification. I haven't made significant progress on this matter.

I failed to locate the current code for the popup player or as I understand the fragment which it is part of. I didn't follow up on this, because I'm currently involved with other stuff.

If nobody else is going to implement this, I will pick it up again, but I have to take some exams first 🥲

AudricV commented 2 years ago

If it's not done by the player and all its components rewrite, I suggest to work on this only after the player rewrite is done.

MominRaza commented 2 years ago

Any update on this? This is most important feature for android 12 user, what is the benefit of pop up media player when you can't interact with other apps. Please devs make it top priority Thanks

infinitytec commented 2 years ago

Curiously, this seems to be working for me with version 0.23.1 on my S22 Ultra. On prior versions, picture-in-pucture was not working.

triallax commented 2 years ago

@infinitytec that bug was fixed in https://github.com/TeamNewPipe/NewPipe/pull/8279. Note that we're still not using Android's PiP player, but our own custom popup player.

AudricV commented 2 years ago

If it's not done by the player and all its components rewrite, I suggest to work on this only after the player rewrite is done.

Note that the player rewrite has been completed. Nothing should prevent now tries to implement this feature, even if changes to its structure/core may be required!