Hi, I am streaming a video but there is no sound. Previously with local videos I added an audio.mp4 to a sound slot and everything works, but how do I control/play the sound of a streamed video?
Thanks
Is the video muted or set to be muted?
Has the user interacted with the page yet (eg a click down)?
If you have a reference to the DOM element of the video, you can control the audio/playback directly.
Yes, has already clicked.
I have access to things like this.video.play(); but how would I make it play the sound too?
Okay, I think I get it. I need to create an 'audio element eg:
this.videoSound = document.createElement('audio');
and then control it with…
this.videoSound.play();
But this plays 2D. How do I base the volume on a 3d position like with the Sound component? Will I need to write the code manually? Cheers
Check the PannerNode API: PannerNode - Web APIs | MDN
If you plan to bypass the regular PlayCanvas sound component and build this on your own.
My question is ‘Do I have a choice’? Can I use the regular sound component with streamed audio?
I think not, @LeXXik did an example using the Web Audio API that you may find useful:
https://playcanvas.com/project/716867/overview/spatial-audio