VideoPlayer: No audio when playing from StreamingAssets

When playing a video by url with the VideoPlayer component I get no audio. The url is of an asset in the StreaamingAssets folder and is of the mp4 format. Was hoping someone could take a look and see what I might be missing.


private void PlayIntroCinematic()
{
    CreateCinematicPlayer();
    PlayCinematicVideo();
}

private void CreateCinematicPlayer()
{
    Camera videoPlayerCamera = (new GameObject("VideoPlayerCamera", typeof(DontDestroyOnLoad))).AddComponent<Camera>();
    videoPlayerCamera.clearFlags = CameraClearFlags.SolidColor;
    videoPlayerCamera.backgroundColor = Color.black;

    videoPlayerCamera.gameObject.AddComponent<AudioListener>();
    audioSource = videoPlayerCamera.gameObject.AddComponent<AudioSource>();
    videoPlayer = videoPlayerCamera.gameObject.AddComponent<VideoPlayer>();

    audioSource.playOnAwake = false;
    videoPlayer.playOnAwake = false;

    videoPlayer.renderMode = VideoRenderMode.CameraNearPlane;
    videoPlayer.source = VideoSource.Url;
    videoPlayer.url = GetVideoUrl();

    videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
    videoPlayer.EnableAudioTrack(0, true);
    videoPlayer.SetTargetAudioSource(0, audioSource);
}

private void PlayCinematicVideo()
{
    videoPlayer.loopPointReached += OnIntroComplete;
    videoPlayer.Play();
    audioSource.Play();
}

Found the issue. As well as the AudioSource setup that needed to be done I also needed to add this line:

videoPlayer.controlledAudioTrackCount = 1;

For context:


videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
videoPlayer.controlledAudioTrackCount = 1;
videoPlayer.EnableAudioTrack(0, true);
videoPlayer.SetTargetAudioSource(0, audioSource);