Skip to content

Commit

Permalink
Minor concurrency fix
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Dec 25, 2024
1 parent 45d59da commit 9b1ecab
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions iTorrent/Core/SceneDelegate/SceneDelegate+AVPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,19 @@ extension SceneDelegate {
extension SceneDelegate {
class AVPlayerDelegates: DelegateObject<SceneDelegate>, AVPlayerViewControllerDelegate {
func playerViewControllerRestoreUserInterfaceForFullScreenExit(_ playerViewController: AVPlayerViewController) async -> Bool {
await withCheckedContinuation { continuation in
Task { @MainActor in
guard let vc = parent.window?.rootViewController?.topPresented else {
return continuation.resume(returning: false)
}
guard let vc = await parent.window?.rootViewController?.topPresented
else { return false }

vc.present(playerViewController, animated: true) {
continuation.resume(returning: true)
}
}
}
await vc.present(playerViewController, animated: true)
return true
}

func playerViewControllerRestoreUserInterfaceForPictureInPictureStop(_ playerViewController: AVPlayerViewController) async -> Bool {
await withCheckedContinuation { continuation in
Task { @MainActor in
guard let vc = parent.window?.rootViewController?.topPresented else {
return continuation.resume(returning: false)
}
guard let vc = await parent.window?.rootViewController?.topPresented
else { return false }

vc.present(playerViewController, animated: true) {
continuation.resume(returning: true)
}
}
}
await vc.present(playerViewController, animated: true)
return true
}
}

Expand Down

0 comments on commit 9b1ecab

Please sign in to comment.