Unity: video is playing without sound (2017.3) - unity3d

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.

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?

Related

No audio heard unless facing audio source unity

I have a script, to play a sound clip when a footstep is taken. I use events in the animation tab, and when I play the sound, it will only be audible if i am looking at the character, or npc, the audio source is in fact on the character, but i don't know what is causing this.
On your AudioSource, you could play around with the 3D sound settings:

Unity Video Player, the video cannot be played properly

I am developing a game for android and ios via Unity. I have to play a video in a scene in the game and I use the video player component for this. I get the video link on local using xampp. And the video I'm trying to play is in mp4 format. But when I start the game, the video cannot be played properly. I am not getting an error, but video looks like the picture I send. I don't know what I'm doing wrong, can you help me? I also share the code I used and related pictures with you.
public VideoPlayer videoplayer;
public string videoUrl="urlgir";
void Start() {
videoplayer.url = videoUrl;
videoplayer.audioOutputMode=VideoAudioOutputMode.AudioSource;
videoplayer.EnableAudioTrack (0, true);
videoplayer.Prepare (); }
I think I found something. I uploaded the video I mentioned to unity again. I got a warning after uploading the video.
VFR warning: 1111 video frames have a different duration than expected 0.0333333s, ranging from 0s to 1.2771s.D:/Program Files/Unity/xxx/Assets/Scenes/hp.mp4 (30FPS) may have variable frame rate (VFR), which is not supported. This may lead to incorrect timing in transcoded clip.
I think the video has unsupported variable frame rate. So I can't run the video as clib or url. Well, does anyone know of this warning? What should be needed?

Unity WebGL video file format

Despite looking at the Unity manual at the video codec requirements, there isn’t an option for WebGL.
I’ve created a scene, and I have added video player which renders the video in the Unity game window; however, when I come to run the game in WebGL the video is playing yet there is no audio. On the GameObject holding the video player, I have attached another GameObject with an audio source but still does not seem to play the video. Have I missed something from my code to enable audio or set the video’s audio to the audio source? I have dragged and dropped the audio source GameObject on to the video player audio source option already.
public GameObject videoPlayerHolder;
void Awake()
{
videoPlayer = this.gameObject.GetComponent<VideoPlayer>();
videoPlayer.Play();
videoPlayer.loopPointReached += EndReached;
videoPlayer.url = Path.Combine(Application.streamingAssetsPath, "Intromemoji-1MP4.mp4");
}
Managed (almost) to answer this question, after a decent length of time with zero answers.
It turns out that any H.264 encoder will create playable the video so long as it is a.Webm file - no other file formats would seem to work for me.
Note: This worked fine for most browsers (Chrome, Firefox, Edge, Opera and Internet Explorer); however, Safari I could not get any video to play with or without sound. I feel this is due to CORS or I read something else to do with iFrames not allowing automatic audio in Safari to prevent noisy popups. Still, I've not found a comprehensive solution to this issue.

Scripting for Facebook AR Studio AudioModule

I've been playing around with Facebook AR but I'm not sure how to script using the AudioModule. The tutorial in facebook's page only explains on using the patch editor but i want to know how to script it as well.
Basically, the audio plays only when a video texture is playing. The video texture only plays after a timeout of 10secs, so the audio should follow suit. Obviously, its sound.play() but how do i get the audio itself?
I have a speaker -> audio : playback_controller_model0
Does using AudioModule require anything? like var Audio = require("Audio"); ?
i did something like :
var Audio = require("Audio");
var sound = Audio.getPlayBackController("playback_controller_model0");
sound.play();
and it doesn't seem to be working though because the video texture script is being ignored.
Unfortunately Facebook recently removed the option to script audio playback in favor or using the Patch Editor to control audio playback. As of the latest version you can only use the Patch Editor to play audio, God knows why... But, you can use the script to patches bridge to trigger playback via script, by sending messages to the playback controller in your Patch from script.
Like so in script:
Patches.setPulseValue('PlayMySound', Reactive.once());
And in the Patches Editor:
Good luck!

Unity VideoPlayer and WebGLMovieTexture cant play two videos in a row

I'm trying to play videos in Unity WebGL in the browser, but having lots of problems.
I tried two different video players and none of them work fully.
The WebGLMovieTexture player works like this
public WebGLStreamingVideoPlugin _videoPlugin = new WebGLStreamingVideoPlugin("http://www.example.net/video.mp4");
_videoPlugin.Play();
Basically when you want to play a video you create a new instance and give it the URL like above, and it plays great!!
The problem is when you want to stop that video, and play a different video, it seems impossible because there is no way dispose of the first video because there is only a Stop() in the API, which stops the playback but it continues to stream the video data from the internet in the background.
There is no way to delete the instance because Destroy() cant be called since that WebGLMovieTexture is not derived from monodevelop, and C# does not seem to give a way to delete an object (how silly). Even setting it to null doesnt do it, it continues to stream the video in the background.
So if you create a new instance in order to play a different video, you end up with TWO video streams, and if you do it again to play a third, you end up with THREE, and so on, so quickly you can see how bad that will end up.
My question is how to dispose of or destroy the first WebGLMovieTexture player, or maybe tell it to stop streaming the first video and start playing a different one?
The second player I tried is the VideoPlayer for WebGL in Unity Version 5.6.0b4, with this one I can only get it to play a video if I hardcode the URL in the inspector, if I put the URL in code it doesn't play it in the browser.
vPlayer = gameObject.GetComponent<UnityEngine.Video.VideoPlayer>();
if (vPlayer.isPlaying) {
Debug.Log("STOPPING PLAY");
vPlayer.Stop();
}
vPlayer.url = url;
vPlayer.isLooping = true;
vPlayer.frame = 0;
vPlayer.targetCameraAlpha = 1F;
vPlayer.Prepare();
vPlayer.Play();
And to get it to play a second video I suspect I will have the same problems as the other one.
Anybody have any ideas that can help me?