|This is no longer a part of the World of Warcraft API.
Play any sound or music native to the game using the audio's ID. Other players will not hear the audio.
local willPlay, soundHandle = PlaySoundKitID(ID, [channel[, forceNoDuplicates]])
- Number - The ID of the audio. According to Wowhead, IDs go up to 50973 as of build 20253. WoW database sites typically display the ID in the url address of the page for a sound file.
- String - "SFX","Music","Ambience" or "Master" (this will play the sound also with disabled sounds like before 4.0.1).
- Boolean - If true, prevents multiple instances of this sound from playing at the same time. Defaults to true.
- Flag - true if the sound will be played, nil otherwise (prevented by a muted sound channel, for instance).
- Number - identifier for the queued playback.
PlaySoundKitID(31749, "master", true); -- UI_PetBattle_Victory
The following plays a random sound or music from the entire game by clicking SomeFrame, stopping the previous audio every click. SomeFrame can be any valid frame for SetScript.
SomeFrame:SetScript('PostClick',function() if soundhandle then StopSound(soundhandle) end local x=random(1,50973) local _,soundhandle=PlaySoundKitID(x) end)