PlaySoundKitID

From Wowpedia
Jump to: navigation, search

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]])

Arguments

ID
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.
channel 
String - "SFX","Music","Ambience" or "Master" (this will play the sound also with disabled sounds like before 4.0.1).
forceNoDuplicates
Boolean - If true, prevents multiple instances of this sound from playing at the same time. Defaults to true.

Returns

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

Examples

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)

Patch changes