Browse Source

Make playImmediately a property of THREE.Audio, rename it to autoplay and defaults to false

Matthew Tung 10 years ago
parent
commit
15ecabbc7c
1 changed files with 5 additions and 3 deletions
  1. 5 3
      src/extras/audio/Audio.js

+ 5 - 3
src/extras/audio/Audio.js

@@ -2,12 +2,14 @@
  * @author mrdoob / http://mrdoob.com/
  */
 
-THREE.Audio = function ( listener ) {
+THREE.Audio = function ( listener, autoplay ) {
 
 	THREE.Object3D.call( this );
 
 	this.type = 'Audio';
 
+	this.autoplay = autoplay || false;
+
 	this.context = listener.context;
 	this.source = this.context.createBufferSource();
 
@@ -25,7 +27,7 @@ THREE.Audio = function ( listener ) {
 THREE.Audio.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Audio.prototype.constructor = THREE.Audio;
 
-THREE.Audio.prototype.load = function ( file, playImmediately ) {
+THREE.Audio.prototype.load = function ( file ) {
 
 	var scope = this;
 
@@ -38,7 +40,7 @@ THREE.Audio.prototype.load = function ( file, playImmediately ) {
 
 			scope.source.buffer = buffer;
 
-			if( playImmediately !== false ) scope.play();
+			if( scope.autoplay ) scope.play();
 
 		} );