question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebAudio Orientation example not working on mobile browser (iOS)

See original GitHub issue
Description of the problem

I am having problems making PositionalAudio work on mobile. I am initialising everything Audio related after a user click like so:

$('#enter-popup').click( function() { 
    $('#enter-popup').hide()
    var AudioContext = window.AudioContext || window.webkitAudioContext    
    audioContext = new AudioContext()
    listener = new THREE.AudioListener()
    camera.add(listener)
    createSoundObjects()
    setupLocalUser()
})

The createSoundObjects method fetches a source url from firebase and uses it for the initialiser of my “Sound” class like so…

this.mediaElement = new Audio(url);
this.mediaElement.loop = true;
this.mediaElement.preload = 'auto';
this.mediaElement.crossOrigin = 'anonymous';
this.mediaElement.play()

This works great on desktop, but I cannot get it to work on mobile (iOS 13, Safari && Chrome && Firefox).

I then proceeded to check out some examples and found out that the official WebAudio Orientation example isn’t working either.

=> https://threejs.org/examples/webaudio_orientation.html

Nothing abnormal is getting logged in my console. please help. Thank you.

Three.js version
  • “three”: “^0.112.1”
Browser
  • All of them
OS
  • iOS
Hardware Requirements (graphics card, VR Device, …)
  • iPhone XS (iOS 13)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
chrisguttandincommented, Feb 26, 2020

Hi everyone, I guess this is caused by a bug in Safari (https://bugs.webkit.org/show_bug.cgi?id=203435) which seems to be fixed but not yet shipped.

1reaction
mrdoobcommented, Feb 18, 2020

Hmm, will test tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebAudio Examples not working on iOS and macOS Safari
Hey folks! I'm working on a music related web-game and am very much new to ThreeJS. Thinks are working fine in Chrome 87...
Read more >
ios - Web Audio API not playing sound sample on device, but ...
When testing in the browser using Ionic Serve (chrome) the audio plays fine. Here is what I have: function snare(e) { var audioSource...
Read more >
PannerNode.orientationZ - Web APIs - MDN Web Docs
An AudioParam whose value is the Z component of the direction the audio source is facing, in 3D Cartesian coordinate space. Example. See ......
Read more >
Web Audio API on iPad | Apple Developer Forums
No problems on iPhone or other compatible browsers. ... Note: On iOS, the Web Audio API requires sounds to be triggered from an...
Read more >
166003 - Support for Web Audio API on Chrome for Android
Here for webaudio/<audio>tag support in chrome for android. i have one ... (See, for example, https://code.google.com/p/chromium/issues/detail?id=232973.)
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found