repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 7d4ca97c076dd59c37e10e9e4d4a17eca695e08e:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 7d4ca97c076dd59c37e10e9e4d4a17eca695e08e
Author: James Baicoianu 
Date:   Fri Jun 12 23:39:04 2020 -0700

    remoteplayer.addVoice()

diff --git a/scripts/remoteplayer.js b/scripts/remoteplayer.js
index 5c0734d8d78393297564cb16fa81a9d03cf9611b..
index ..d02241b074851e5d3ff8a0caa9084d934205cd0c 100644
--- a/scripts/remoteplayer.js
+++ b/scripts/remoteplayer.js
@@ -131,6 +131,25 @@ elation.component.add('engine.things.remoteplayer', function() {
       //console.log('already playing');
     }
   }
+  this.addVoice = function(stream) {
+    this.mouth = this.createObject('sound', { pos: V(0, 0, 0), distanceModel: 'exponential' });
+    this.head.add(this.mouth._target);
+    this.mouth.createAudio();
+
+    let panner = this.mouth.audio.panner,
+        context = panner.context,
+        source = context.createMediaStreamSource(stream);
+
+    if (this.engine.systems.sound.canPlaySound) {
+      source.connect(panner);
+      this.mouth.audio.play();
+    } else {
+      elation.events.add(this.engine.systems.sound, 'sound_enabled', (ev) => {
+        source.connect(panner);
+        this.mouth.audio.play();
+      });
+    }
+  }
 }, elation.engine.things.janusghost);

 });

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