Skip to main content
Version: iOS 1.0.12

Stream Screen Capture

Stream a Screen Capture of Your App#

This example creates a webview and broadcasts your apps screen.

Please note that streaming is paused if you move your app into background. To enable streaming from background, you will have to implement a broadcast extension.

override func viewDidLoad() {
// Prepare webview that we are going to broadcast
view.addSubview(webView)
webView.anchor(top: view.topAnchor, leading: view.leadingAnchor, bottom: view.bottomAnchor, trailing: view.trailingAnchor)
webView.navigationDelegate = self
let url = URL(string: "https://www.video.io")!
webView.load(URLRequest(url: url))
webView.allowsBackForwardNavigationGestures = true
let vkLive = VKLiveStream()
// Set streaming mode to screen and audio capture
vkLive.streamingMode = .appScreenCaptureAndAudio
// Start Broadcasting
vkLive.host(type: .lowLatency) { (stream, error) in
guard let stream = stream else {
print("There was an error starting your stream.")
return
}
print("Stream started: \(stream.id)")
print("Playback url: " + stream.getPlaybackUrl()?.absoluteString ?? "Error retrieving stream URL")
}
}
Last updated on by Nikita Gaer