Как настроить расширение загрузки широковещательной рассылки, как показывает программа просмотра на экране записи?
Ниже транслируется настройка viewController
import ReplayKit
class BroadcastSetupViewController: UIViewController {
// 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 = URL(string:"http://apple.com/broadcast/streamID")
// Dictionary with setup information that will be provided to broadcast extension when broadcast is started
let setupInfo: [String : NSCoding & NSObjectProtocol] = ["broadcastName": "example" 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: "YouAppDomain", code: -1, userInfo: nil)
// Tell ReplayKit that the extension was cancelled by the user
self.extensionContext?.cancelRequest(withError: error)
}
}
Это то, что я имею в контроллере настройки трансляции.
Ниже приведен код для класса sampleHandler:
import ReplayKit
class SampleHandler: RPBroadcastSampleHandler {
override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) {
// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
}
override func broadcastPaused() {
// User has requested to pause the broadcast. Samples will stop being delivered.
}
override func broadcastResumed() {
// User has requested to resume the broadcast. Samples delivery will resume.
}
override func broadcastFinished() {
// User has requested to finish the broadcast.
}
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
switch sampleBufferType {
case RPSampleBufferType.video:
// Handle video sample buffer
break
case RPSampleBufferType.audioApp:
// Handle audio sample buffer for app audio
break
case RPSampleBufferType.audioMic:
// Handle audio sample buffer for mic audio
break
}
}
}
Это то, что в моем классе sampleHandler. Кто-нибудь может мне помочь, почему я не могу транслировать ScreenRecord? Любое предложение?