PlaySoundFile

From Warcraft Wiki
Jump to navigation Jump to search
Flavors
Links
Info
Added in 1.0.0

Plays the specified sound by FileDataID or addon file path.

willPlay, soundHandle = PlaySoundFile(sound [, channel])

Arguments

sound
number|string - Either a FileDataID, or the path to a sound file from an addon.
  • The file must exist prior to logging in or reloading. Both .ogg and .mp3 formats are accepted.
channel
string? = SFX - The sound channel.
Channel Toggle CVar Volume CVar[1]
Master Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil). Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil).
Music Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil). Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil).
SFX (Effects) Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil). Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil).
Ambience Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil). Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil).
Dialog Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil). Lua error in Module:Apitooltip at line 30: bad argument #2 to 'format' (string expected, got nil).
Talking Head[2]
Volume sliders in the interface options

Returns

willPlay
boolean - true if the sound will be played, nil otherwise (prevented by a muted sound channel, for instance).
soundHandle
number - identifier for the queued playback.

Example

Plays a sound file included with your addon and ignores any sound setting except the master volume slider:

  • Both slash / or escaped backslashes \\ can be used as file separators.
PlaySoundFile("Interface\\AddOns\\MyAddOn\\mysound.ogg", "Master")

Plays the level up sound:

-- by file path (dropped in 8.2.0)
PlaySoundFile("Sound/Spells/LevelUp.ogg")
-- by FileDataID 569593 (added support in 8.2.0)
PlaySoundFile(569593)
-- by SoundKitID 888 (SoundKitName LEVELUP)
PlaySound(888)

Finding Sound IDs

File Data IDs

Sound Kit Names/IDs

Patch changes

Battle for Azeroth Patch 8.2.0 (2019-06-25): Updated to accept FileDataIDs due to the removal of file paths.[3]

See also