Our platform sends audio over webRTC from the AudioListener, so if the audio is output some other way, the stream will not receive them. To ensure that the audio from videos in the game is included in the WebRTC audio stream, make sure the audio output from the videos is routed through the AudioListener used for the WebRTC audio track.
To achieve this:
- Add an AudioSource for the Video - Ensure each video has an AudioSource component attached. This component should play the video's audio.
- Route the AudioSource to the AudioListener - Ensure the AudioSource components are routed through the AudioListener used in the WebRTC setup.
Please see sample code below to help get you started:
using UnityEngine;
using UnityEngine.Video;
public class VideoAudioSetup : MonoBehaviour
{
public VideoPlayer videoPlayer;
private AudioSource audioSource;
void Start()
{
audioSource = gameObject.AddComponent<AudioSource>();
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
videoPlayer.SetTargetAudioSource(0, audioSource);
}
}