Consume html5 media element audio in PositionalAudio

Hi guys, I would like to consume audio coming from <video> element in a PositionalAudio node (so it can be placed in the 3d space). I’ve found that Audio node supports a method setMediaElementSource which works with media elements, the problem is that it is not positional (audio doesn’t change no matter where the listener is). Is there any hack/workaround to make it work with PositionalAudio instead?

const video = document.getElementById('myVideo');
const listener = new THREE.AudioListener();
camera.add(listener);

const audio = new THREE.Audio(listener); // would like to use PositionalAudio instead
audio.setMediaElementSource(video);

Can you try it like in this example? three.js webaudio - orientation

It uses a PositionalAudio and also setMediaElementSource().

1 Like

Works perfectly! I didn’t notice that PositionalAudio extends Audio class, so it inherits all the functionalities. Awesome, thanks for the help!