Swift
Integrate with Vonage Video Manager
Now that the driver is built, you need to tell the Vonage SDK to use your driver instead of the default one. This will be done in your VonageVideoManager.swift.
import OpenTok
import SwiftUI
final class VonageVideoManager: NSObject, ObservableObject {
let kAppId = "YOUR_APP_ID"
let kSessionId = "YOUR_SESSION_ID"
let kToken = "YOUR_TOKEN"
private var myAudioDevice: AudioDeviceRingtone?
/**
* The setup needs to be called in order to activate the VonageVideoMAnager
* it can be used e.g. in the .task { } method, when the view gets loaded
**/
public func setup() {
// 1. Initialize your custom audio device with a ringtone file
if let path = Bundle.main.path(forResource: "bananaphone", ofType: "mp3") {
myAudioDevice = AudioDeviceRingtone(ringtone: URL(fileURLWithPath: path))
// 2. Set the global audio device for Vonage SDK
// IMPORTANT: This must be done before creating a session
OTAudioDeviceManager.setAudioDevice(myAudioDevice)
}
doConnect()
}
// ... Session connection logic (doConnect, etc) ...
}
Custom audio driver
Learn how to use a custom audio driver to customize publisher and subscriber stream audio. You will use the custom audio driver when you want to start and stop the audio, and play your own audio file. When you want to do "anything" with audio, other than the SDK default behavior of live video chat, you would use custom audio drivers.
Available on:
Steps
1
Introduction2
Getting Started3
Creating a New Project4
Adding the Vonage Video SDK5
Setting Up Authentication6
Overview7
Create the Custom Audio Driver Class8
Implement the "Play Ringtone" Logic9
Implement the "Stop Ringtone" Logic10
Integrate with Vonage Video Manager11
Control audio via Session Events12
How It Works13
Conclusion