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

Pip window turns black when launch the local camera app #16

Open
ismail-go opened this issue Nov 21, 2024 · 5 comments
Open

Pip window turns black when launch the local camera app #16

ismail-go opened this issue Nov 21, 2024 · 5 comments

Comments

@ismail-go
Copy link

Hi! Your strategy was working well until the published ios 18.
When i run on the devices which are ios 17, There is no problem and when I try to run it ios 18 still no problem
but after the launching the local native camera app while pip mode is running,
the pip window turns the black.

Do you have any idea about this?

@ibrahimdevs
Copy link

@CaiWanFeng, Apple changed window class for iOS 18. In iOS 17, there is another type scene class for pip window and when we open camera app, pip window scene still foreground active. But in iOS 18, Apple uses UIWindowScene class for pip window, and it becomes background when we open camera app, then if we close the camera app, it become foreground active again.

I tried some other alternative categories and modes for audio session to solve it but no success.

It can be made, because some apps still provides this function on iOS 18 too.
@Ben-Spotec fyi.

@CaiWanFeng
Copy link
Owner

@ismail-go @ibrahimdevs Code updated and make sure your Xcode version is below 16.0.

@ibrahimdevs
Copy link

@CaiWanFeng
I think code update includes only hide all native controls of pip, instead of hide progress.

Why did you mention that Xcode should below 16? We spent some time to what causes this issue. And detect it is not working when we build with Xcode 16 like you said, but it is working when we build with Xcode 15.

Is there any way to work it with Xcode 16 or do you know why this is not working with Xcode 16? Because we have to publish our apps only with Xcode 16 after 2025. So we can’t send new builds after 1 month.

Thanks 🙏

@CaiWanFeng
Copy link
Owner

@ibrahimdevs
Apple did not provide public Interface for us so we have to customize our pip with KVC to access private properties.

I guess Apple did not care whether these custom pip is work or not in new SDK. What's more, maybe Apple did not want we to use these KVC technologies at all.

@MrSouthWall
Copy link

@CaiWanFeng @ismail-go @ibrahimdevs @Ben-Spotec

Hi guys, I've been looking for a way to do this recently, and with the help of rednote users "Previs Shot 分镜" and "Claude" AI, I've found the following implementation:

TestUIPiPView.txt

You can add TestUIPiPView() to any SwiftUI view to test the demo, and don't forget to set the project's "Background Modes".

Here are my guesses:

Apple recognizes two ways to use picture-in-picture, one is to play a video and the other is to make a video call.

As you know from the above dialog, picture-in-picture for playing videos is automatically disabled when the camera is enabled in versions higher than iOS 18 and Xcode 16.

But picture-in-picture works fine if you use video calls, I think it might be because Apple thinks that video calls must be kept available.

Apple Documents: https://developer.apple.com/documentation/avkit/adopting-picture-in-picture-for-video-calls

But it's still a problem:

  • I have not found a way to modify the size of the video call picture-in-picture.
  • In the regular playback video picture-in-picture, there are control buttons in the upper left and right corners, but not in the video call picture-in-picture.
  • If you tap on the video call picture-in-picture, you will immediately go back to the App.

嗨!各位好,我最近也在寻找相关的方法,在小红书用户「Previs Shot 分镜」和「Claude」AI 的帮助下,找到了以下实现方式:

TestUIPiPView.txt

你可以在任意 SwiftUI 视图内添加 TestUIPiPView() 以测试 Demo,别忘了设置项目的「Background Modes」。

以下是我的猜测:

苹果认可使用画中画的方式有两种,一种是播放视频,另一种则是视频通话。
通过以上对话了解,在高于 iOS 18 和 Xcode 16 版本时,播放视频的画中画会在启用相机后自动禁用。
但是如果使用视频通话的画中画则可以正常运行,我想可能是苹果认为视频通话必须保持可用的状态。

苹果文档:https://developer.apple.com/documentation/avkit/adopting-picture-in-picture-for-video-calls

但它仍然存在问题:

  • 我没有找到修改视频通话画中画尺寸的方式。
  • 在常规的播放视频画中画中,左上角和右上角会有控制按钮,但是在视频通话画中画中却没有。
  • 如果您轻点视频通话画中画,会立即回到 App。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants