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 Sound_EnableAllSoundSound_EnableAllSound (Sound)
Default: 1
Sound_MasterVolumeSound_MasterVolume (Sound)
Default: 1.0
master volume (0.0 to 1.0)
Music Sound_EnableMusicSound_EnableMusic (Sound)
Default: 1
Enables music
Sound_MusicVolumeSound_MusicVolume
Default: 0.4
SFX (Effects) Sound_EnableSFXSound_EnableSFX (Sound)
Default: 1
Sound_SFXVolumeSound_SFXVolume (Sound)
Default: 1.0
sound volume (0.0 to 1.0)
Ambience Sound_EnableAmbienceSound_EnableAmbience (Sound)
Default: 1
Enable Ambience
Sound_AmbienceVolumeSound_AmbienceVolume
Default: 0.6
Dialog Sound_EnableDialogSound_EnableDialog (Sound)
Default: 1
all dialog
Sound_DialogVolumeSound_DialogVolume (Sound)
Default: 1.0
Dialog Volume (0.0 to 1.0)
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