Hey there,
i have problems running spatial Audio with THREE.PositionalAudio( );
HTMLMediaElements with a file as source working fine but with a MediaStreamObject i´m not able to hear it spatial (just global). (Chrome, Firefox and Safari all acted the same)
This code here runs perfectly:
<audio id="test_audio" src="/music/test.mp3"></audio>
const listener = new THREE.AudioListener();
player_local.object.add(listener);
var voice_src = game.document.getElementById("test_audio");
var voice = new THREE.PositionalAudio( listener );
voice.setMediaElementSource(voice_src);
voice.setRefDistance( 5 );
voice.setDirectionalCone( 180, 230, 1 );
player_remote.object.add(voice);
voice_src.play();
Within this snippet, i can hear the sound, but not spatial:
// MediaStreamObject coming from Peer.js connection
const audio = document.createElement('audio');
audio.srcObject = stream;
const listener = new THREE.AudioListener();
player_local.object.add(listener);
var voice_src = game.document.getElementById(idOfStreamAudioElement);
var voice = new THREE.PositionalAudio( listener );
voice.setMediaStreamSource(voice_src.srcObject);
voice.setRefDistance( 5 );
voice.setDirectionalCone( 180, 230, 1 );
player_remote.object.add(voice);
voice_src.play();
The same code was presented as a solution right here:
Any ideas why this still does not work?