我使用LFLivekit为facebook这样的单一平台进行了直播。当我尝试两个平台时,它没有发生。
码:
import UIKit
import LFLiveKit
class VideoViewController: UIViewController {
var sessionO: LFLiveSession =
{
let audioConfiguration = LFLiveAudioConfiguration.defaultConfiguration(for: LFLiveAudioQuality.high)
let videoConfiguration = LFLiveVideoConfiguration.defaultConfiguration(for: LFLiveVideoQuality.low3)
let session = LFLiveSession(audioConfiguration: audioConfiguration, videoConfiguration: videoConfiguration)
return session!
}()
override func viewDidLoad() {
super.viewDidLoad()
self.streamUrl = "live-api-s.facebook.com:80/rtmp/"
self.streamName = "17XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
self.sessionO.delegate = self
self.sessionO.preView = self.view
self.sessionO.running = true
}
override func viewDidAppear(_ animated: Bool)
{
super.viewDidAppear(animated)
let stream = LFLiveStreamInfo()
stream.url = "rtmp://\(self.streamUrl!)/LiveApp/\(self.streamName!)"
self.sessionO.startLive(stream)
}
}
注意:如果我再为youtube创建一个会话和流,则它无效。
我们需要创建单独的RTMP连接并创建监听器。
fbRtmpStream = RTMPStream(connection: fbRtmpConnection)
ytRtmpStream = RTMPStream(connection: ytRtmpConnection)
self.fbRtmpConnection1.addEventListener(Event.RTMP_STATUS, selector:#selector(self.fbRtmpStatusHandler1(_:)), observer: self)
self.fbRtmpConnection1.connect("rtmp://live-api-s.facebook.com:80/rtmp/")
self.fbStreamName1 = "xxxxxx"
self.ytRtmpConnection.addEventListener(Event.RTMP_STATUS, selector:#selector(self.ytRtmpStatusHandler(_:)), observer: self)
self.ytRtmpConnection.connect("rtmp://a.rtmp.youtube.com/live2/LiveApp/")
self.ytStreamName = "xxxxxxxxx"