Swift
Configure the Vonage Session for Screen Sharing
In your session/video manager:
- Create a view to be able to see screensharing working real-time we'll use a simple timer
final class VonageVideoManager: NSObject, ObservableObject {
@Published var timeStamp: String = "00:00:00.00"
fileprivate let formatter: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .short
dateFormatter.timeStyle = .long
return dateFormatter
}()
public func setup() {
Timer.scheduledTimer(withTimeInterval: TimeInterval(1), repeats: true) { [weak self] _ in
guard let self else { return }
self.timeStamp = self.formatter.string(from: Date())
}
doConnect()
}
// ...
then assign it in View:
struct ContentView: View {
@ObservedObject var videoManager = VonageVideoManager()
var body: some View {
VStack {
Text(videoManager.timeStamp)
.background(.red)
.frame(width: 200, height: 200, alignment: .center)
.cornerRadius(5.0)
}
.task {
videoManager.setup()
}
}
}
- Create an
OTPublisherwithvideoType = .screenandaudioFallbackEnabled = false. - Assign the custom capturer before publishing:
publisher.videoType = .screen
publisher.audioFallbackEnabled = false
let rootView = UIApplication.shared.rootViewController?.view ?? UIView()
capturer = ScreenCapturer(withView: rootView)
publisher.videoCapture = capturer
publisher.videoCapture?.videoContentHint = .text
session.publish(publisher, error: &error)
- Publish the publisher – the screen share stream will be sent to the session.
Screen sharing
Learn how to implement tha screensharing capability using the Vonage Video API platform.
手順
1
Introduction2
Getting Started3
Creating a New Project4
Adding the Vonage Video SDK5
Setting Up Authentication6
Create the Screen Capturer7
Expose the Root View for FullScreen Capture8
Expose the Root View for FullScreen Capture9
Summary10
Conclusion