From 522b9ebb7799ee8889aa79dd945959bf55c5d71e Mon Sep 17 00:00:00 2001 From: Kofktu Date: Thu, 20 Jan 2022 10:04:09 +0900 Subject: [PATCH 1/2] Add func renderPictureInPicture() --- PIPKit/Classes/AVPIPKit/AVPIPKitRenderer.swift | 10 +++++++--- PIPKit/Classes/AVPIPKit/AVPIPKitUsable+UIKit.swift | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/PIPKit/Classes/AVPIPKit/AVPIPKitRenderer.swift b/PIPKit/Classes/AVPIPKit/AVPIPKitRenderer.swift index 146d369..515e8dd 100644 --- a/PIPKit/Classes/AVPIPKit/AVPIPKitRenderer.swift +++ b/PIPKit/Classes/AVPIPKit/AVPIPKitRenderer.swift @@ -26,7 +26,7 @@ final class AVPIPUIKitRenderer: AVPIPKitRenderer { let policy: AVPIPKitRenderPolicy var renderPublisher: AnyPublisher { - render.eraseToAnyPublisher() + _render.eraseToAnyPublisher() } var exitPublisher: AnyPublisher { _exit.eraseToAnyPublisher() @@ -35,7 +35,7 @@ final class AVPIPUIKitRenderer: AVPIPKitRenderer { private var isRunning: Bool = false private weak var targetView: UIView? private var displayLink: CADisplayLink? - private let render = PassthroughSubject() + private let _render = PassthroughSubject() private let _exit = PassthroughSubject() deinit { @@ -78,6 +78,10 @@ final class AVPIPUIKitRenderer: AVPIPKitRenderer { _exit.send(()) } + func render() { + onRender() + } + // MARK: - Private @objc private func onRender() { guard let targetView = targetView else { @@ -85,7 +89,7 @@ final class AVPIPUIKitRenderer: AVPIPKitRenderer { return } - render.send(targetView.uiImage) + _render.send(targetView.uiImage) } } diff --git a/PIPKit/Classes/AVPIPKit/AVPIPKitUsable+UIKit.swift b/PIPKit/Classes/AVPIPKit/AVPIPKitUsable+UIKit.swift index 6455ed4..6056bea 100644 --- a/PIPKit/Classes/AVPIPKit/AVPIPKitUsable+UIKit.swift +++ b/PIPKit/Classes/AVPIPKit/AVPIPKitUsable+UIKit.swift @@ -16,6 +16,9 @@ public protocol AVPIPUIKitUsable: AVPIPKitUsable { var renderPolicy: AVPIPKitRenderPolicy { get } var exitPublisher: AnyPublisher { get } + // If you want to update the screen, execute the following additional code. + func renderPictureInPicture() + } @available(iOS 15.0, *) @@ -50,6 +53,11 @@ public extension AVPIPUIKitUsable where Self: UIViewController { videoController?.stop() } + func renderPictureInPicture() { + setupRendererIfNeeded() + avUIKitRenderer?.render() + } + // MARK: - Private private func setupRendererIfNeeded() { guard avUIKitRenderer == nil else { From 6ee03c23fe2148bf358f73a91ee2da20a2f6391e Mon Sep 17 00:00:00 2001 From: Kofktu Date: Thu, 20 Jan 2022 10:05:20 +0900 Subject: [PATCH 2/2] 1.0.5 Release Add func renderPictureInPicture() --- PIPKit.podspec | 2 +- PIPKit.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PIPKit.podspec b/PIPKit.podspec index 5acec85..1cf71a8 100644 --- a/PIPKit.podspec +++ b/PIPKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'PIPKit' - s.version = '1.0.4' + s.version = '1.0.5' s.summary = 'PIP(Picture in Picture) for iOS' # This description is used to generate tags and improve search results. diff --git a/PIPKit.xcodeproj/project.pbxproj b/PIPKit.xcodeproj/project.pbxproj index 7440acc..709039a 100644 --- a/PIPKit.xcodeproj/project.pbxproj +++ b/PIPKit.xcodeproj/project.pbxproj @@ -504,7 +504,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.0.5; PRODUCT_BUNDLE_IDENTIFIER = kr.kofktu.PIPKit; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -533,7 +533,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.0.5; PRODUCT_BUNDLE_IDENTIFIER = kr.kofktu.PIPKit; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES;