Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
m (add Dialog as a channel option, fix casing, remove 4.0 note)
No edit summary
Tag: WoW API docs
(20 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{wowapi}} __NOTOC__
+
{{wowapi}}
 
Play one of a set of built-in sounds. Other players will not hear the sound.
 
Play one of a set of built-in sounds. Other players will not hear the sound.
local willPlay, soundHandle = PlaySound("soundName", "channel", throttle)
+
willPlay, soundHandle = PlaySound(soundKitID [, channel, forceNoDuplicates, runFinishCallback])
   
 
==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.
;soundName : String - One of the below sound names (not all these actually make a sound)
 
  +
;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>
<div style="border: 2px solid #404040; overflow-y: auto; height: 14em; margin-left: 2.5em; padding: 0.2em"><div style="margin-left: -1.5em;">
 
  +
;forceNoDuplicate : {{api|t=t?|boolean}} - Allow duplicate sounds if false. Defaults to true.
: PVPENTERQUEUE - Sound for entering BG queue and when it refreshes periodicly
 
  +
;runFinishCallback : {{api|t=t?|boolean}} - Fires {{api|t=e|SOUNDKIT_FINISHED}} when sound is done, arg1 will be soundHandle given below. Defaults to false.
: PVPTHROUGHQUEUE - You are eligible to enter the battleground!
 
  +
: GLUESCREENSMALLBUTTONMOUSEDOWN
 
  +
[[Image:API_PlaySoundFile_channels.png|thumb|Sound channels]]
: GLUESCREENSMALLBUTTONMOUSEUP
 
: GLUESCREENSMALLBUTTONMOUSEOVER
 
: GLUESCREENMEDIUMBUTTONMOUSEDOWN
 
: GLUESCREENMEDIUMBUTTONMOUSEUP
 
: GLUESCREENMEDIUMBUTTONMOUSEOVER
 
: GLUESCREENLARGEBUTTONMOUSEDOWN
 
: GLUESCREENLARGEBUTTONMOUSEUP
 
: GLUESCREENLARGEBUTTONMOUSEOVER
 
: GLUESCREENEDITBOXKEYCLICK
 
: GLUECHECKBOXMOUSEDOWN
 
: GLUECHECKBOXMOUSEUP
 
: GLUECHECKBOXMOUSEOVER
 
: GLUECHARCUSTOMIZATIONMOUSEDOWN
 
: GLUECHARCUSTOMIZATIONMOUSEUP
 
: GLUECHARCUSTOMIZATIONMOUSEOVER
 
: GLUESCROLLBUTTONMOUSEDOWN
 
: GLUESCROLLBUTTONMOUSEUP
 
: GLUESCROLLBUTTONMOUSEOVER
 
: GAMEABILITYBUTTONMOUSEDOWN
 
: GAMESPELLBUTTONMOUSEDOWN
 
: GAMEWINDOWOPEN
 
: GAMEWINDOWCLOSE
 
: GAMEDIALOGOPEN
 
: GAMEDIALOGCLOSE
 
: GAMENEWWINDOWTAB
 
: GAMESCREENSMALLBUTTONMOUSEDOWN
 
: GAMESCREENSMALLBUTTONMOUSEUP
 
: GAMESCREENSMALLBUTTONMOUSEOVER
 
: GAMESCREENMEDIUMBUTTONMOUSEDOWN
 
: GAMESCREENMEDIUMBUTTONMOUSEUP
 
: GAMESCREENMEDIUMBUTTONMOUSEOVER
 
: GAMESCREENLARGEBUTTONMOUSEDOWN
 
: GAMESCREENLARGEBUTTONMOUSEUP
 
: GAMESCREENLARGEBUTTONMOUSEOVER
 
: GAMETARGETFRIENDLYUNIT
 
: GAMETARGETHOSTILEUNIT
 
: GAMETARGETNEUTRALUNIT
 
: GAMEHIGHLIGHTFRIENDLYUNIT
 
: GAMEHIGHLIGHTHOSTILEUNIT
 
: GAMEHIGHLIGHTNEUTRALUNIT
 
: GAMEINITIALATTACK
 
: GAMEERROROUTOFRANGE
 
: GAMEERROROUTOFMANA
 
: GAMEERRORUNABLETOEQUIP
 
: GAMEERRORINVALIDTARGET
 
: ACTIONBARBUTTONDOWN
 
: MAINBUTTONBARMENU
 
: MINIMAPZOOMOUT
 
: MINIMAPZOOMIN
 
: MINIMAPOPEN
 
: MINIMAPCLOSE
 
: BAGMENUBUTTONPRESS
 
: LOOTWINDOWOPEN
 
: LOOTWINDOWCLOSE
 
: LOOTWINDOWCOINSOUND
 
: ITEMWEAPONSOUND
 
: ITEMARMORSOUND
 
: ITEMGENERICSOUND
 
: LEVELUPSOUND
 
: GLUECREATECHARACTERBUTTON
 
: GLUEENTERWORLDBUTTON
 
: SPELLBOOKOPEN
 
: SPELLBOOKCLOSE
 
: SPELLBOOKCHANGEPAGE
 
: PAPERDOLLOPEN
 
: PAPERDOLLCLOSE
 
: QUESTADDED
 
: QUESTCOMPLETED
 
: QUESTLOGOPEN
 
: QUESTLOGCLOSE
 
: GLUEGENERICBUTTONPRESS
 
: GAMEGENERICBUTTONPRESS
 
: INTERFACESOUND_MONEYFRAMEOPEN
 
: INTERFACESOUND_MONEYFRAMECLOSE
 
: INTERFACESOUND_CHARWINDOWOPEN
 
: INTERFACESOUND_CHARWINDOWCLOSE
 
: INTERFACESOUND_CHARWINDOWTAB
 
: INTERFACESOUND_GAMEMENUOPEN
 
: INTERFACESOUND_GAMEMENUCLOSE
 
: INTERFACESOUND_LOSTTARGETUNIT
 
: INTERFACESOUND_BACKPACKOPEN
 
: INTERFACESOUND_BACKPACKCLOSE
 
: INTERFACESOUND_GAMESCROLLBUTTON
 
: INTERFACESOUND_CURSORGRABOBJECT
 
: INTERFACESOUND_CURSORDROPOBJECT
 
: SHEATHINGSHIELDSHEATHE
 
: SHEATHINGWOODWEAPONSHEATHE
 
: SHEATHINGMETALWEAPONSHEATHE
 
: SHEATHINGWOODWEAPONUNSHEATHE
 
: SHEATHINGMETALWEAPONUNSHEATHE
 
: SHEATHINGSHIELDUNSHEATHE
 
: igCreatureAggroDeselect
 
: igQuestListOpen
 
: igQuestListClose
 
: igQuestListSelect
 
: igQuestListComplete
 
: igQuestCancel
 
: igPlayerInvite
 
: igPlayerInviteAccept
 
: igPlayerInviteDecline
 
: GAMEERRORUNABLETOEQUIP
 
: ITEMGENERICSOUND
 
: GAMEERRORINVALIDTARGET
 
: LEVELUP
 
: GAMEERROROUTOFRANGE
 
: QUESTADDED
 
: MONEYFRAMEOPEN
 
: MONEYFRAMECLOSE
 
: LOOTWINDOWOPEN
 
: LOOTWINDOWCLOSE
 
: LOOTWINDOWCOINSOUND
 
: GAMEHIGHLIGHTHOSTILEUNIT
 
: GAMEHIGHLIGHTNEUTRALUNIT
 
: GAMEHIGHLIGHTFRIENDLYUNIT
 
: INTERFACESOUND_LOSTTARGETUNIT
 
: INTERFACESOUND_CURSORGRABOBJECT
 
: INTERFACESOUND_CURSORDROPOBJECT
 
: GAMESCREENMEDIUMBUTTONMOUSEDOWN
 
: GAMEABILITYACTIVATE
 
: GAMESPELLACTIVATE
 
: gsTitleEnterWorld
 
: gsTitleOptions
 
: gsTitleQuit
 
: gsTitleCredits
 
: gsTitleIntroMovie
 
: gsTitleOptionScreenResolution
 
: gsTitleOption16bit
 
: gsTitleOption32bit
 
: gsTitleOptionOpenGL
 
: gsTitleOptionDirect3D
 
: gsTitleOptionFullScreenMode
 
: gsTitleOptionOK
 
: gsTitleOptionExit
 
: gsLogin
 
: gsLoginNewAccount
 
: gsLoginChangeRealm
 
: gsLoginExit
 
: gsLoginChangeRealmOK
 
: gsLoginChangeRealmSelect
 
: gsLoginChangeRealmCancel
 
: gsCharacterSelection
 
: gsCharacterSelectionEnterWorld
 
: gsCharacterSelectionDelCharacter
 
: gsCharacterSelectionAcctOptions
 
: gsCharacterSelectionExit
 
: gsCharacterSelectionCreateNew
 
: gsCharacterCreationClass
 
: gsCharacterCreationRace
 
: gsCharacterCreationGender
 
: gsCharacterCreationLook
 
: gsCharacterCreationCreateChar
 
: gsCharacterCreationCancel
 
: igCurrentActiveSpell
 
: igMiniMapOpen
 
: igMiniMapClose
 
: igMiniMapZoomIn
 
: igMiniMapZoomOut
 
: igChatEmoteButton
 
: igChatScrollUp
 
: igChatScrollDown
 
: igChatBottom
 
: igSpellBookOpen
 
: igSpellBookClose
 
: igSpellBokPageTur n
 
: igSpellBookSpellIconPickup
 
: igSpellBookSpellIconDrop
 
: igAbilityOpen
 
: igAbilityClose
 
: igAbiliityPageTurn
 
: igAbilityIconPickup
 
: igAbilityIconDrop
 
: TalentScreenOpen
 
: TalentScreenClose
 
: igCharacterInfoOpen
 
: igCharacterInfoClose
 
: igCharacterInfoTab
 
: igCharacterInfoScrollUp
 
: igCharacterInfoScrollDown
 
: igQuestLogOpen
 
: igQuestLogClose
 
: igQuestLogAbandonQuest
 
: igQuestFailed
 
: igSocialOepn (sic)
 
: igSocialClose
 
: igMainMenuOpen
 
: igMainMenuClose
 
: igMainMenuOption
 
: igMainMenuLogout
 
: igMainMenuQuit
 
: igMainMenuContinue
 
: igMainMenuOptionCheckBoxOn
 
: igMainMenuOptionCheckBoxOff
 
: igMainMenuOptionFaerTab
 
: igInventoryOepn (sic)
 
: igInventoryClose
 
: igInventoryRotateCharacter
 
: igBackPackOpen
 
: igBackPackClose
 
: igBackPackCoinSelect
 
: igBackPackCoinOK
 
: igBackPackCoinCancel
 
: igCharacterNPCSelect
 
: igCharacterNPCDeselect
 
: igCharacterSelect
 
: igCharacterDeselect
 
: igCreatureNeutralSelect
 
: igCreatureNeutralDeselect
 
: igCreatureAggroSelect
 
: UChatScrollButton
 
: Deathbind Sound
 
: LOOTWINDOWOPENEMPTY
 
: TaxiNodeDiscovered
 
: UnwrapGift
 
: TellMessage
 
: WriteQuest
 
: MapPing
 
: igBonusBarOpen
 
: FriendJoinGame
 
: Fishing Reel in
 
: HumanExploration
 
: OrcExploration
 
: UndeadExploration
 
: TaurenExploration
 
: TrollExploration
 
: NightElfExploration
 
: GnomeExploration
 
: DwarfExploration
 
: igPVPUpdate
 
: ReadyCheck
 
: RaidWarning
 
: AuctionWindowOpen
 
: AuctionWindowClose
 
</div></div>
 
;channel : String - Either "Master", "SFX", "Ambience", "Music", or "Dialog".
 
;throttle : Boolean - Setting to false will disable the (default on) throttle which prevents you from playing the exact same sound until playback of the first sound has finished.
 
   
 
== Returns ==
 
== Returns ==
; willPlay : Flag - true if the sound will be played, nil otherwise (prevented by a muted sound channel, for instance).
+
; willPlay : {{api|t=t|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.
+
; soundHandle : {{api|t=t|number}} - identifier for the queued playback.
   
 
==Example==
 
==Example==
  +
Plays the ready check sound file (''sound/interface/levelup2.ogg'')
PlaySound("LEVELUPSOUND", "master");
 
  +
PlaySound(SOUNDKIT.READY_CHECK) -- by SOUNDKIT key
  +
PlaySound(8960) -- by SoundKitID
  +
  +
{{api|PlaySoundFile}}(567478) -- by FileDataID
  +
  +
==Finding Sound IDs==
  +
{{:API_PlaySoundFile}}
   
 
== Patch history ==
 
== Patch history ==
  +
* {{Patch 7.3.0|note=Changed. String-based input is not allowed. SoundKitID should be given while calling ''PlaySound()''. This change is more like a replacement for {{api|PlaySoundKitID}}.}}
{{Patch 5.0.4|note=Added <tt>willPlay</tt> and <tt>soundHandle</tt> return values.}}
 
  +
* {{Patch 7.0.3|note=Added fourth argument, <code>runFinishCallback</code>.}}
  +
* {{Patch 5.0.4|note=Added <code>willPlay</code> and <code>soundHandle</code> return values.}}
  +
* {{Patch 1.1.0|note=Added.}}
   
 
== See also ==
 
== See also ==
  +
* {{api|PlaySoundFile}} - Accepts FileDataIDs and addon file paths.
* {{api|PlaySoundKitID}}
 
 
* {{api|StopSound}}
 
* {{api|StopSound}}
  +
  +
==External links==
  +
<!-- Please read https://wow.gamepedia.com/Wowpedia:External_links_policy before adding new links. -->
  +
{{Elinks-api}}
  +
  +
==References==

Revision as of 19:19, 15 April 2021

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", "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.
API PlaySoundFile channels

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 (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 (2016-07-19): Added fourth argument, runFinishCallback.
  • Mists of Pandaria Patch 5.0.4 (2012-08-28): Added willPlay and soundHandle return values.
  • WoW Icon update Patch 1.1.0 (2004-11-07): Added.

See also

External links

References