<#C0346LWVBJ4|> I'm trying to pause the AVPlayer v...
# compose-ios
y
#C0346LWVBJ4 I'm trying to pause the AVPlayer video when in Full screen. Now when another window is opened the player is not paused it still continue playing behind this new window. I'm adding new window using this code.
Copy code
val scene = UIApplication.sharedApplication.connectedScenes.first() as? UIWindowScene
val overlayWindow: UIWindow? = scene?.let { UIWindow(it) }
overlayWindow?.setFrame(UIScreen.mainScreen.bounds)
overlayWindow?.setWindowLevel(UIWindowLevelAlert + 1)
overlayWindow?.hidden = false
overlayWindow?.rootViewController = overlayViewController
overlayWindow?.makeKeyAndVisible()
I'm able to show and hide the window everything works fine. But when this window is shown the player compose state is still resume and playing
m
you could observe notification when the window becomes key? https://developer.apple.com/documentation/uikit/uiwindow/didbecomekeynotification
VideoPlayer.swift.cpp
assuming you have something which owns your AVPlayer layer like this. you could check
if self.window?.isKey == false {
in order to pause video