如何在图片模式下开始图片而不是进入背景?像YouTube Premium

发布于 2025-01-24 09:38:08 字数 342 浏览 4 评论 0原文

我知道当应用程序正常运行时,如何启用图片中的图片模式本身,但是问题在于,当应用程序转到AcrackeD Mode IE时,我想激活它。 这种行为的一个很好的例子是Android上的YouTube Premium应用程序。当视频播放时,用户点击“主页”按钮时,视频只是在PIP模式下继续播放。 我尝试实现LifeCycleObserver,并从其“ OnPause”回调中启动图片中的图片模式。但是它说“必须恢复活动才能进入图片中”。 我在OnPope方法中查看了一个,它以Super.Onpause()的方式实现,因此我不能仅仅覆盖它,也不能称为“ Super”。

有人对如何实施这种类似YouTube的行为有任何建议吗? PS我在问这个之前已经搜索了很多

I know how to enable picture-in-picture mode itself when an app runs normally but the problem is that I want to activate it when the app goes to background mode i.e. on activity pause.
A good example of such behavior is YouTube premium app on android. When a video is playing and a user taps "home" button the video just keeps on playing in PIP mode.
I tried to implement LifecycleObserver and launch picture-in-picture mode from its "onPause" callback. But it says "activity must be resumed to enter picture-in-picture".
I took a look inside onPause method and it's implemented in a way that super.onPause() must be called first, so I can't just override it and not to call "super".

Does anyone have any suggestion on how implement this Youtube-like behavior?
p.s. I've googled a lot before asking this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东京女 2025-01-31 09:38:08

文档为此提供了一个示例:

@Override
public void onUserLeaveHint () {
    if (iWantToBeInPipModeNow()) {
        enterPictureInPictureMode();
    }
}

https> https:// deverseer。 android.com/guide/topics/ui/picture-in-picture#pip_button

The docs provide an example for this:

@Override
public void onUserLeaveHint () {
    if (iWantToBeInPipModeNow()) {
        enterPictureInPictureMode();
    }
}

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文