Skip to content

Commit 1e2721b

Browse files
committed
Implement Android method enterPipMode
1 parent da82dff commit 1e2721b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

android/java/org/chromium/chrome/browser/app/BraveActivity.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,27 @@ public void showYouTubeFeaturesLayout(final boolean show) {
27322732
}
27332733
}
27342734

2735+
public void enterPipMode() {
2736+
if (!deviceSupportedPictureInPictureMode(this)) {
2737+
Toast.makeText(this, R.string.picture_in_picture_not_supported, Toast.LENGTH_LONG).show();
2738+
return;
2739+
}
2740+
2741+
if (!hasPictureInPicturePermissionEnabled(this)) {
2742+
launchPictureInPictureSettings(this);
2743+
return;
2744+
}
2745+
2746+
final Tab currentTab = getActivityTab();
2747+
if (TabUtils.isYouTubeVideo(currentTab)) {
2748+
if (getLifecycleDispatcher().getCurrentActivityState() != RESUMED_WITH_NATIVE) {
2749+
return;
2750+
}
2751+
BackgroundVideoPlaybackTabHelper.setFullscreen(currentTab.getWebContents());
2752+
enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
2753+
}
2754+
}
2755+
27352756
@Override
27362757
public void onUserInteraction() {
27372758
super.onUserInteraction();

0 commit comments

Comments
 (0)