Steps to reproduce:
Prerequiste: A microphone or headset needs to be connected to the device.
- Open attached project [Internal link] .
- Click on "File > Build Profiles".
- Switch to Web platform.
- Click on "Build & Run".
- In the browser allow to access to the microphone
- Check for errors in browser console
Actual results: An error is logged to the browser console "Can't get data from microphone sound clip because data is not yet decompressed." and data is not loaded.
Expected results: The audio data is loaded and "Got Clips successfully!" is logged to the console.
Reproducible with versions: 6000.4.0b7, 6000.5.0a1, 6000.6.0a1
Not reproducible with versions: None
Can’t test with versions: Versions before 6000.4 do not support the Microphone API on the Web Platform.
Tested on (OS): Windows 11
Notes:
- The main issue is that AudioClip.loadState seems to return a wrong state for a brief moment after Microphone.End(deviceId) is called. It should report Loading immediatly after recording is stopped while the compressed audio data is still decoding. Instead it is reporting Loaded at first before it switches to Loading.
- As a workaround it is possible to wait for a few seconds after calling Microphone.End(deviceId) before querying the loadState.
- Prebuild project [Internal link] [Internal link]
- Bug was reported by user on the forums: https://discussions.unity.com/t/microphone-audio-load-state-issue-in-webgl/1712173/14