Audio on Safari / IOS not working

var audiolistener = new THREE.AudioListener();
camera.add( me.audiolistener );

var sound = new THREE.Audio( audiolistener );
	var audioLoader = new THREE.AudioLoader();
	audioLoader.load( 'SOMEAUDIO.wav', function( buffer ) {
	sound.setBuffer( buffer );
	sound.setLoop(false);
	sound.setVolume(0.5);
	sound.play();
});

this works on android browsers, and desktop

Author: Fantashit

1 thought on “Audio on Safari / IOS not working

  1. i just spent a lot of time figuring this out because i want to use positional audio for a web project and finally got it working, so i figured i’d share here since this got me going in the right direction. basically the source comes from the audioListener context.

    this is in my init function:

    function playSound() {
      audioLoader.load("clips/theme_80.mp3", function(buffer) {
        sound.setBuffer( buffer );
        sound.setRefDistance( 20 );
        sound.play();
      });
    
      var source = listener.context.createBufferSource();
      source.connect(listener.context.destination);
      source.start();
    }
    window.addEventListener('touchstart', playSound);
    document.addEventListener('click', playSound);
    

    seems to work on mobile safari and chrome, though only tested on my iphone.

    here’s the test version:
    https://owenroberts.github.io/char/sound.html

Comments are closed.