-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBroadcastSetupViewController.swift
34 lines (26 loc) · 1.34 KB
/
BroadcastSetupViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import ReplayKit
class BroadcastSetupViewController: UIViewController {
// MARK: Replace These Values
let broadcastName = "My Recording"
let myErrorDomain = "My Error Domain"
private let fileManager: FileManager = .default
override func viewDidAppear(_ animated: Bool) {
userDidFinishSetup()
}
// Call this method when the user has finished interacting with the view controller and a broadcast stream can start
func userDidFinishSetup() {
// URL of the resource where broadcast can be viewed that will be returned to the application
let broadcastURL = fileManager.temporaryDirectory
.appendingPathComponent(UUID().uuidString)
.appendingPathExtension(for: .mpeg4Movie)
// Dictionary with setup information that will be provided to broadcast extension when broadcast is started
let setupInfo: [String : NSCoding & NSObjectProtocol] = ["broadcastName": broadcastName as NSCoding & NSObjectProtocol]
// Tell ReplayKit that the extension is finished setting up and can begin broadcasting
self.extensionContext?.completeRequest(withBroadcast: broadcastURL, setupInfo: setupInfo)
}
func userDidCancelSetup() {
let error = NSError(domain: myErrorDomain, code: -1, userInfo: nil)
// Tell ReplayKit that the extension was cancelled by the user
self.extensionContext?.cancelRequest(withError: error)
}
}