Last active
August 25, 2019 08:52
-
-
Save FromAtom/d6a0f39d0cdb41b2affeb851f5724138 to your computer and use it in GitHub Desktop.
RPBroadcastActivityViewController のサンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import ReplayKit | |
class ViewController: UIViewController { | |
private var broadcastController: RPBroadcastController? | |
private func startBroadcast() { | |
RPBroadcastActivityViewController.load { broadcastAVC, error in | |
guard let broadcastAVC = broadcastAVC else { return } | |
broadcastAVC.delegate = self | |
self.present(broadcastAVC, animated: true) | |
} | |
} | |
private func finishBroadcast() { | |
broadcastController?.finishBroadcast(handler: { (error) in | |
print(error) | |
}) | |
broadcastController = nil | |
} | |
} | |
extension ViewController: RPBroadcastActivityViewControllerDelegate { | |
func broadcastActivityViewController(_ broadcastActivityViewController: | |
RPBroadcastActivityViewController, didFinishWith broadcastController: RPBroadcastController?, error: Error?) { | |
self.broadcastController = broadcastController | |
self.broadcastController?.delegate = self | |
DispatchQueue.main.async { | |
broadcastActivityViewController.dismiss(animated: true) { | |
broadcastController?.startBroadcast { error in | |
print(error) | |
} | |
} | |
} | |
} | |
} | |
extension ViewController: RPBroadcastControllerDelegate { | |
func broadcastController(_ broadcastController: RPBroadcastController, didFinishWithError error: Error?) { | |
print(error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment