- Home /
Question by
Braza · May 17, 2020 at 02:01 PM ·
audiowebglaudiosourceaudioclip
Browsers prevent WebGL Audio to start at Awake. How to get notification of actual Audio start?
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.
I use PlaySheduled to play smooth looping clips back-to-back. This requires me to calculate schedule starting from the 1st clip started at Awake. But Browsers won't let Unity play audio until Canvas is clicked. This causes Scheduled clips to overlap. How can I get notified in Unity when WebGL actually started playing music?
Here's scheduling logic:
musicSource.PlayScheduled(nextStartTime);
// Checks how long the Clip will last and updates the Next Start Time with a new value
double duration = (double)musicSource.clip.samples / musicSource.clip.frequency;
nextStartTime = nextStartTime + duration;
Comment
Your answer
Follow this Question
Related Questions
Play audio at consistent volume 2 Answers
Problem with playing sound on Trigger-Enter 2 Answers
How to get decibel's value of game's sound? 0 Answers
Looping an audio while holding "shift key" 1 Answer
AudioSource won't play 2 Answers