MBS
MBS

Reputation: 707

Unity: video is playing without sound (2017.3)

When using unity 2017.1 Video is played with sound. And audio without a video also played well.

When I upgrade to unity 2017.3 video is played without sound, while audio file without video is played well (sound is on).

Edit:

When building the application to windows sound is working. The problem seems to appear only in editor.

Upvotes: 2

Views: 2892

Answers (1)

MBS
MBS

Reputation: 707

After sending a bug to unity, they respond after a long time.

The solution was adding this line when assigning the Audio from Video to AudioSource to be played.

private VideoPlayer _videoPlayer;

.
.
.
.
.

    //Assign the Audio from Video to AudioSource to be played
    _videoPlayer.controlledAudioTrackCount = 1;             // <-- We have added this line. It tells video player that you will have one audio track playing in Unity AudioSource.
    _videoPlayer.EnableAudioTrack(0, true);
    _videoPlayer.SetTargetAudioSource(0, _audioSource);

But still don't know why it is working without this line on previous versions (2017.2 for example)? and why it is also working without this line on exe build?

Upvotes: 3

Related Questions