Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-18-15, 07:54 AM   #1
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
"Sound XZ is missing" alert

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:
  1. local LSM = LibStub("LibSharedMedia-3.0")
  2. LSM:Register("sound", "SoundPack: Alarm_01", [[Interface\Addons\SoundPack\01_Alarms+Bells\Alarm_01.ogg]])

Lua Code:
  1. local LSM3 = LibStub("LibSharedMedia-3.0", true)
  2. local LSM2 = LibStub("LibSharedMedia-2.0", true)
  3. local SML = LibStub("SharedMedia-1.0", true)
  4.  
  5. SoundPack = {}
  6. SoundPack.revision = tonumber(string.sub("$Revision$", 12, -3)) or 1
  7.  
  8. function SoundPack:Register(mediatype, key, data, langmask)
  9.     if LSM3 then
  10.         LSM3:Register(mediatype, key, data, langmask)
  11.     end
  12.     if LSM2 then
  13.         LSM2:Register(mediatype, key, data)
  14.     end
  15.     if SML then
  16.         SML:Register(mediatype, key, data)
  17.     end
  18.     if not SoundPack.registry[mediatype] then
  19.         SoundPack.registry[mediatype] = {}
  20.     end
  21.     table.insert(SoundPack.registry[mediatype], { key, data, langmask})
  22. end
  23.  
  24. function SoundPack.OnEvent(this, event, ...)
  25.     if not LSM3 then
  26.         LSM3 = LibStub("LibSharedMedia-3.0", true)
  27.         if LSM3 then
  28.             for m,t in pairs(SoundPack.registry) do
  29.                 for _,v in ipairs(t) do
  30.                     LSM3:Register(m, v[1], v[2], v[3])
  31.                 end
  32.             end
  33.         end
  34.     end
  35.     if not LSM2 then
  36.         LSM2 = LibStub("LibSharedMedia-2.0", true)
  37.         if LSM2 then
  38.             for m,t in pairs(SoundPack.registry) do
  39.                 for _,v in ipairs(t) do
  40.                     LSM2:Register(m, v[1], v[2])
  41.                 end
  42.             end
  43.         end
  44.     end
  45.     if not SML then
  46.         SML = LibStub("SharedMedia-1.0", true)
  47.         if SML then
  48.             for m,t in pairs(SoundPack.registry) do
  49.                 for _,v in ipairs(t) do
  50.                     SML:Register(m, v[1], v[2])
  51.                 end
  52.             end
  53.         end
  54.     end
  55. end
  56.  
  57. SoundPack.frame = CreateFrame("Frame")
  58. SoundPack.frame:SetScript("OnEvent", SoundPack.OnEvent)
  59. SoundPack.frame:RegisterEvent("ADDON_LOADED")
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » "Sound XZ is missing" alert


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off