Difference between revisions of "API PlaySound"

From Wowpedia
Jump to: navigation, search
Tag: WoW API docs
m
Tag: WoW API docs
Line 5: Line 5:
 
==Arguments==
 
==Arguments==
 
;soundKitID : {{api|t=t|number}} - All sounds used by Blizzard's UI are defined in the [https://github.com/Gethe/wow-ui-source/blob/live/SharedXML/SoundKitConstants.lua SOUNDKIT] table.
 
;soundKitID : {{api|t=t|number}} - All sounds used by Blizzard's UI are defined in the [https://github.com/Gethe/wow-ui-source/blob/live/SharedXML/SoundKitConstants.lua SOUNDKIT] table.
;channel : {{api|t=t?|string}} - The sound volume slider setting the sound should use, one of: <code>"Master"</code>, <code>"SFX"</code>, <code>"Music"</code>, <code>"Ambience"</code>, <code>"Dialog"</code>. Individual channels (except "Master") have user-configurable volume settings and may be muted, preventing playback. Defaults to <code>"SFX"</code> if not specified. There is also a <code>"Talking Head"</code> channel.<ref>https://github.com/Gethe/wow-ui-source/blob/9.0.5/AddOns/Blizzard_TalkingHeadUI/Blizzard_TalkingHeadUI.lua#L199</ref>
+
;channel : {{api|t=t?|string}} - The sound volume slider setting the sound should use, one of: <code>"Master"</code>, <code>"SFX"</code> (Sound), <code>"Music"</code>, <code>"Ambience"</code>, <code>"Dialog"</code>. Individual channels (except "Master") have user-configurable volume settings and may be muted, preventing playback. Defaults to <code>"SFX"</code> if not specified. There is also a <code>"Talking Head"</code> channel.<ref>https://github.com/Gethe/wow-ui-source/blob/9.0.5/AddOns/Blizzard_TalkingHeadUI/Blizzard_TalkingHeadUI.lua#L199</ref>
 
;forceNoDuplicate : {{api|t=t?|boolean}} - Allow duplicate sounds if false. Defaults to true.
 
;forceNoDuplicate : {{api|t=t?|boolean}} - Allow duplicate sounds if false. Defaults to true.
 
;runFinishCallback : {{api|t=t?|boolean}} - Fires {{api|t=e|SOUNDKIT_FINISHED}} when sound is done, arg1 will be soundHandle given below. Defaults to false.
 
;runFinishCallback : {{api|t=t?|boolean}} - Fires {{api|t=e|SOUNDKIT_FINISHED}} when sound is done, arg1 will be soundHandle given below. Defaults to false.

Revision as of 00:10, 16 May 2021

Game Flavors
Links
Patch
Added in 1.1.0 / 1.13.2

Play one of a set of built-in sounds. Other players will not hear the sound.

willPlay, soundHandle = PlaySound(soundKitID [, channel, forceNoDuplicates, runFinishCallback])

Arguments

soundKitID 
number - All sounds used by Blizzard's UI are defined in the SOUNDKIT table.
channel 
string?Optional. Could be nil. - The sound volume slider setting the sound should use, one of: "Master", "SFX" (Sound), "Music", "Ambience", "Dialog". Individual channels (except "Master") have user-configurable volume settings and may be muted, preventing playback. Defaults to "SFX" if not specified. There is also a "Talking Head" channel.[1]
forceNoDuplicate 
boolean?Optional. Could be nil. - Allow duplicate sounds if false. Defaults to true.
runFinishCallback 
boolean?Optional. Could be nil. - Fires SOUNDKIT_FINISHED when sound is done, arg1 will be soundHandle given below. Defaults to false.
Sound channels

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 the ready check sound file (sound/interface/levelup2.ogg)

PlaySound(SOUNDKIT.READY_CHECK) -- by SOUNDKIT key
PlaySound(8960) -- by SoundKitID
PlaySoundFile(567478) -- by FileDataID

Finding Sound IDs

File Data IDs

Sound Kit Names/IDs

Patch history

  • Legion Patch 7.3.0 / API (2017-08-29): Changed. String-based input is not allowed. SoundKitID should be given while calling PlaySound(). This change is more like a replacement for PlaySoundKitID.
  • Legion Patch 7.0.3 / API (2016-07-19): Added fourth argument, runFinishCallback.
  • Mists of Pandaria Patch 5.0.4 / API (2012-08-28): Added willPlay and soundHandle return values.
  • WoW Icon update.png Patch 1.1.0 / API (2004-11-07): Added.

See also

External links

References