repo: janusweb action: commit revision: path_from: revision_from: 7d4ca97c076dd59c37e10e9e4d4a17eca695e08e: path_to: revision_to:
commit 7d4ca97c076dd59c37e10e9e4d4a17eca695e08e Author: James BaicoianuDate: Fri Jun 12 23:39:04 2020 -0700 remoteplayer.addVoice() diff --git a/scripts/remoteplayer.js b/scripts/remoteplayer.js
--- 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-----