我有点沮丧,我无法停止声音。我使用了关于如何在三个j中播放声音的示例代码,并且在play()下,我想停下来测试。当我在游戏中停止声音时无关紧要,我得到同样的错误:
TypeError:参数不足
我没想到调用stop()需要任何参数。我在Safari和Firefox上运行。
任何帮助将不胜感激!
这是我的代码:
//实例化一个监听器 var audioListener = new THREE.AudioListener();
// add the listener to the camera
camera.add( audioListener );
// instantiate audio object
var oceanAmbientSound = new THREE.Audio( audioListener );
// add the audio object to the scene
scene.add( oceanAmbientSound );
// instantiate a loader
var loader = new THREE.AudioLoader();
// load a resource
loader.load(
// resource URL
'sounds/mySound.mp3',
// Function when resource is loaded
function ( audioBuffer ) {
// set the audio object buffer to the loaded object
oceanAmbientSound.setBuffer( audioBuffer );
// play the audio
oceanAmbientSound.play();
oceanAmbientSound.stop();
},
// Function called when download progresses
function ( xhr ) {
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
},
// Function called when download errors
function ( xhr ) {
console.log( 'An error happened' );
}
答案 0 :(得分:0)
想出它 - 它必须是我的旧版Safari(8.0.8)。尽管如此,感谢您的帮助!