repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 4457d85b4118ead4fb329c77b57a9d2413b76fb8:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 4457d85b4118ead4fb329c77b57a9d2413b76fb8
Author: James Baicoianu 
Date:   Sun Apr 18 23:15:42 2021 -0700

    async video.initSound()

diff --git a/scripts/video.js b/scripts/video.js
index 879393843d8797d4868e280686b90c2753e3c0bb..
index ..7c40d6635f2293056dc6057767a8d30b27fb7250 100644
--- a/scripts/video.js
+++ b/scripts/video.js
@@ -85,29 +85,29 @@ elation.require(['janusweb.janusbase'], function() {
       }
       this.adjustAspectRatio();
     }
-    this.initSound = function() {
-      var listener = this.engine.systems.sound.getRealListener(),
-          ctx = listener.context;
-      this.audionodes = {
-        listener: listener,
-        ctx: ctx
-      };
+    this.initSound = async function() {
+      return new Promise(async (resolve, reject) => {
+        let roomaudionodes = await this.room.getAudioNodes(),
+            ctx = roomaudionodes.listener.context;
+        this.audionodes = {
+          listener: roomaudionodes.listener,
+          ctx: ctx
+        };

-      var source = this.getSoundSource();
+        var source = this.getSoundSource();

-      this.soundobj = new THREE.PositionalAudio(listener);
-      this.objects['3d'].add(this.soundobj);
-      this.soundobj.isPlaying = true;
-      //this.panner = this.context.createPanner();
+        this.soundobj = new THREE.PositionalAudio(roomaudionodes.listener);
+        this.objects['3d'].add(this.soundobj);
+        this.soundobj.isPlaying = true;
+        source.connect(this.soundobj.panner);

-      //this.panner.connect(ctx.destination);
-      //gainnode.connect(this.panner);
-      source.connect(this.soundobj.panner);
+        this.audionodes.source = source;
+        this.audionodes.gain = this.soundobj.gain;
+        this.audionodes.panner = this.soundobj.panner;
+        this.audionodes.gain.value = this.gain;

-      this.audionodes.source = source;
-      this.audionodes.gain = this.soundobj.gain;
-      this.audionodes.panner = this.soundobj.panner;
-      this.audionodes.gain.value = this.gain;
+        this.audionodes.gain.connect(roomaudionodes.gain);
+      });
     }
     this.getSoundSource = function() {
       if (!this.video._audiosource) {

-----END OF PAGE-----