From e5c1aff8edc56d0f94b3ad5da05fd5816b52ac2f Mon Sep 17 00:00:00 2001
From: netpro2k <netpro2k@gmail.com>
Date: Mon, 9 Jul 2018 19:07:02 -0700
Subject: [PATCH] Fix issue with postional audio on multiple instances of the
 same video

---
 src/components/image-plus.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/components/image-plus.js b/src/components/image-plus.js
index 152e9d459..2a0a2c5d0 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;
-- 
GitLab