Interaction Requirement for Enabling Microphone

Mario_Perez
Fri, 29 Nov 2024 16:28:59 +0000
Technical Support

Hi, I think 8thwall studio is very good, I’m trying out the free license with this code to interact with the microphone of a device.

My problem is that Android devices require physical interaction from the user for the permission to be enabled.

function setAudio() {
const _windows : any = window

if (audioContext) return

audioContext = new (window.AudioContext || _windows.webkitAudioContext)()

analyzer = audioContext.createAnalyser()
analyzer.fftSize = 256
dataArray = new Uint8Array(analyser.frequencyBinCount)

// Get access to the microphone
try {
navigator.mediaDevices
.getUserMedia({audio: true})
.then((stream) => {
const source = audioContext.createMediaStreamSource(stream)
source.connect(analyser)

mediaDeviceLoad = true
})
} catch (err) {
console.error(‘Error accessing microphone:’, err)
}
}

How can I add this interaction? Currently, when loading the application, the 8thwall logo appears and the user must click on it at that moment to enable the microphone, otherwise, when entering my application (without interacting with the 8thwall logo) the application will no longer obtain the permissions.

On the other hand, I want to know, if I buy the Pro license (month), will the Splash Screen be removed?

2 posts - 2 participants