Hey, I'm currently working much with my AddOn
Sound Pack. It adds many new sounds to your Shared Media Library.
Now I woud like to have a chat print warning or something like this if I registered a sound file wong. Currently the file is showing up but there is no error it just won't play. Woud make it much more easy than to test all 350 files ingame.
http://wow.gamepedia.com/API_PlaySoundFile
There does not appear to be a bad error if the file is missing - it just won't play. There is a return status, which is 1 if the sound was OK and nil if it couldn't be found.
|
Current code:
Lua Code:
local LSM = LibStub("LibSharedMedia-3.0")
LSM:Register("sound", "SoundPack: Alarm_01", [[Interface\Addons\SoundPack\01_Alarms+Bells\Alarm_01.ogg]])
Lua Code:
local LSM3 = LibStub("LibSharedMedia-3.0", true)
local LSM2 = LibStub("LibSharedMedia-2.0", true)
local SML = LibStub("SharedMedia-1.0", true)
SoundPack = {}
SoundPack.revision = tonumber(string.sub("$Revision$", 12, -3)) or 1
function SoundPack:Register(mediatype, key, data, langmask)
if LSM3 then
LSM3:Register(mediatype, key, data, langmask)
end
if LSM2 then
LSM2:Register(mediatype, key, data)
end
if SML then
SML:Register(mediatype, key, data)
end
if not SoundPack.registry[mediatype] then
SoundPack.registry[mediatype] = {}
end
table.insert(SoundPack.registry[mediatype], { key, data, langmask})
end
function SoundPack.OnEvent(this, event, ...)
if not LSM3 then
LSM3 = LibStub("LibSharedMedia-3.0", true)
if LSM3 then
for m,t in pairs(SoundPack.registry) do
for _,v in ipairs(t) do
LSM3:Register(m, v[1], v[2], v[3])
end
end
end
end
if not LSM2 then
LSM2 = LibStub("LibSharedMedia-2.0", true)
if LSM2 then
for m,t in pairs(SoundPack.registry) do
for _,v in ipairs(t) do
LSM2:Register(m, v[1], v[2])
end
end
end
end
if not SML then
SML = LibStub("SharedMedia-1.0", true)
if SML then
for m,t in pairs(SoundPack.registry) do
for _,v in ipairs(t) do
SML:Register(m, v[1], v[2])
end
end
end
end
end
SoundPack.frame = CreateFrame("Frame")
SoundPack.frame:SetScript("OnEvent", SoundPack.OnEvent)
SoundPack.frame:RegisterEvent("ADDON_LOADED")