Audio in WebGLA JavaScript API that renders 2D and 3D graphics in a web browser. The Unity WebGL build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info
See in Glossary is done differently then on all other platforms. On other platforms we use FMOD internally to supply audio playback and mixing. Since the WebGL platform does not support threads, we need to use a different implementation, which is internally based on the Web Audio API, which lets the browser handle audio playback and mixing for us.
Unfortunately, this limits audio functionality in Unity WebGL to supporting only the most basic features. This page will document what is expected to work. Anything not listed here is not currently supported on WebGL.
Audio sources support basic positional audio playback with pausing and resuming, panning, rolloff, pitch setting, and doppler effect support.
The following AudioSource
APIs are supported:
Properties
clip
dopplerLevel
ignoreListenerPause
ignoreListenerVolume
isPlaying
loop
maxDistance
minDistance
mute
pitch
(Note that only positive values for pitch are supported.)playOnAwake
rolloffMode
time
timeSamples
velocityUpdateMode
volume
Methods
Pause
Play
PlayDelayed
PlayOneShot
PlayScheduled
SetScheduledEndTime
SetScheduledStartTime
Stop
UnPause
PlayClipAtPoint
All AudioListener
APIs are supported.
Audio clips in WebGL will always be imported in the AAC format, as that is widely supported by different browsers.
The following AudioClip
APIs are supported:
Properties
Methods
AudioClip.Create
is supported partially: it only works if the streaming parameter is set to false and the complete audio samples can be loaded at the time AudioClip.Create
is called. It then creates the clip and loads all samples before returning control.AudioClip.SetData
is supported partially: it only works for replacing the entire contents of the AudioClip. The offsetSamples
parameter is ignored.
SystemInfo.supportsAudio
is not implemented on WebGL and always returns true.
WWW.audioClip
should work in WebGL, if the audio clipA container for audio data in Unity. Unity supports mono, stereo and multichannel audio assets (up to eight channels). Unity can import .aif, .wav, .mp3, and .ogg audio file format, and .xm, .mod, .it, and .s3m tracker module formats. More info
See in Glossary is in a format which is natively supported by the browser. See Mozilla’s documentation on supported media formats for a list of supported formats in different browsers.
The Microphone
class is not supported in WebGL.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!