使用广播 UI 扩展显示 UI(可能是故事板) [英] Display UI (storyboard possibly) with Broadcast UI Extension
问题描述
我对 IOS 编程有点陌生,我正在尝试使用 Replaykit 开始直播,我在从应用程序调用广播服务选择器视图以及创建 2 个扩展(广播上传)方面取得了一些进展扩展和广播 UI 扩展).显然,一旦从选择器视图中选择了扩展程序,就应该加载广播 UI 扩展程序,而另一个在广播开始后接收数据,我在第一个中尝试通过创建故事板并为其提供一个自定义类来创建视图使用广播 UI 扩展程序,但是当我从选择器视图中单击扩展程序时,我立即收到错误用户拒绝应用程序录制
(不确定我是否在这里遗漏了任何步骤),获取在没有情节提要的情况下也出现了同样的错误,我在广播 UI 扩展视图控制器的 override func viewDidLoad()
中尝试了 print()
并且在调试区域中没有日志,所以我甚至不知道它是否被加载.
I'm a bit new to IOS programming, I'm trying to start a live broadcast using Replaykit, I've made some progress in calling the broadcast service picker view from the App and also in creating 2 extensions (Broadcast Upload Extension and Broadcast UI extension).
Apparently the Broadcast UI extension should be loaded once the extension is selected from the picker view and the other receives data once broadcast begins, I've tried in the first to create a view by creating a storyboard and giving it a custom class that's the same with that of the Broadcast UI extension however when I then click on the extension from the picker view I get the immediate error The user declined application recording
(not sure if I'm missing any step here), get this same error without the storyboard too, I tried print()
in override func viewDidLoad()
of the Broadcast UI extension view controller and got no logs in the debug area so I don't even know if it gets loaded at all.
我需要的是显示简单的 UI,然后调用广播 UI 扩展视图控制器函数 (func userDidFinishSetup()
),然后开始广播.如果广播可以在没有 UI 的情况下直接在应用程序中启动,我也会接受,在 Replaykit 文档 我看到了一个 startBroadcast
函数,我认为可以实现这一点,得到了一个 broadcastInvalidSession = -5808
错误,这意味着我试图在没有前一届会议".非常感谢帮助,谢谢.
What I need is to display simple UI that'll then call a Broadcast UI extension view controller function (func userDidFinishSetup()
) that'll then begin the broadcast. I'll also accept if the broadcast can be started directly within the App without the UI, in the Replaykit docs I saw a startBroadcast
function I thought could achieve this, got a broadcastInvalidSession = -5808
error which means I "attempted to start a broadcast without a prior session". Help greatly appreciated, thanks.
广播 UI 视图控制器
Broadcast UI view controller
import ReplayKit
class BroadcastSetupViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print("WASSUP?");
}
// Call this method when the user has finished interacting with the view controller and a broadcast stream can start
func userDidFinishSetup() {
print("GET IN!!!");
// 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)
}
}
推荐答案
于是我联系了 Apple 技术支持事件(遗憾的是),他们建议我将NSExtensionMainStoryboard"添加到类似于 Greg 的广播 UI 扩展的 info.plist回答,当这不起作用时,我发送了我的代码,我们发现我还必须从阻止加载的同一位置删除NSExtensionPrincipalClass"键,之后它工作正常.
So I reached out to Apple technical support incident(regrettably), they suggested I add "NSExtensionMainStoryboard" to the info.plist of the broadcast UI extension similar to Greg's answer, when that didn't work I sent over my code and we found out that I also had to delete "NSExtensionPrincipalClass" key from the same place as that was preventing it from loading, after that it worked fine.
这篇关于使用广播 UI 扩展显示 UI(可能是故事板)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!