diff --git a/src/components/image-plus.js b/src/components/image-plus.js index 152e9d459f6797674fb2638540e2f4ec84489347..2a0a2c5d02e174e19d98705b7652eb56a030a4ce 100644 --- a/src/components/image-plus.js +++ b/src/components/image-plus.js @@ -196,10 +196,6 @@ AFRAME.registerComponent("image-plus", { texture.flipY = false; texture.needsCorrectionFlipY = true; } - - const sound = new THREE.PositionalAudio(this.el.sceneEl.audioListener); - sound.setMediaElementSource(videoEl); - this.el.setObject3D("sound", sound); }); }, @@ -239,6 +235,12 @@ AFRAME.registerComponent("image-plus", { textureCache.set(url, { count: 1, texture }); } + + if (contentType.startsWith("video")) { + const sound = new THREE.PositionalAudio(this.el.sceneEl.audioListener); + sound.setMediaElementSource(texture.image); + this.el.setObject3D("sound", sound); + } } catch (e) { console.error("Error loading media", this.data.src, e); texture = errorTexture;