Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitallysavvy/fb93c4aa9e3de60aead539b4e93c139f to your computer and use it in GitHub Desktop.
Save digitallysavvy/fb93c4aa9e3de60aead539b4e93c139f to your computer and use it in GitHub Desktop.
Snippet for the loadView function within ARSupportBroadcasterViewController
override func loadView() {
super.loadView()
createUI() // init and add the UI elements to the view
self.view.backgroundColor = UIColor.black // set the background color
// Agora setup
guard let appID = getValue(withKey: "AppID", within: "keys") else { return } // get the AppID from keys.plist
let agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: appID, delegate: self) // - init engine
agoraKit.setChannelProfile(.communication) // - set channel profile
let videoConfig = AgoraVideoEncoderConfiguration(size: AgoraVideoDimension1280x720, frameRate: .fps60, bitrate: AgoraVideoBitrateStandard, orientationMode: .fixedPortrait)
agoraKit.setVideoEncoderConfiguration(videoConfig) // - set video encoding configuration (dimensions, frame-rate, bitrate, orientation
agoraKit.enableVideo() // - enable video
agoraKit.setVideoSource(self.arVideoSource) // - set the video source to the custom AR source
agoraKit.enableExternalAudioSource(withSampleRate: 44100, channelsPerFrame: 1) // - enable external audio souce (since video and audio are coming from seperate sources)
self.agoraKit = agoraKit // set a reference to the Agora engine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment