View Single Post
02-18-15, 12:02 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, as far as I know the only way to "test" a sound in-game is to play it. If you wanted to do it automatically without audibly playing the sound, I'd try setting the "Ambience" sound volume to 0, playing the sound on the "Ambienc" channel and checking the return value, then restoring the "Ambience" volume to whatever it was before. You might need to use a slightly higher value than 0, but I'd try 0 first.

However, I'm pretty sure there's also a limit on the number of sounds that can be playing at once, so you'd also need to implement some kind of queue. It's probably not worth the effort, especially since there would be interference with other addons and/or the default UI playing sounds during the test. I'd suggest partly or completely automating the process (see the MyMedia instructions in SharedMedia) so you can't screw it up by typing a file name wrong.

Also, LibSharedMedia-2.0 has been deprecated for years (it uses Ace2, which was discontinued with the launch of WotLK, so it probably doesn't even work anymore) and there never was any such thing as LibSharedMedia-1.0 (the predecessor to 2.0 was called SurfaceLib, and won't work anymore either) so you can clean up your code quite a bit by removing those. There's also no point in delaying the registration of media. Just load LibSharedMedia-3.0 (typically embedded in your addon) and then register your media directly:

Code:
## Interface: 60000
## Title: Sound Pack
## OptionalDeps: LibSharedMedia-3.0

Libs\LibStub\LibStub.lua
Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua
Libs\LibSharedMedia-3.0\LibSharedMedia-3.0.lua

SoundPack.lua
Code:
local ADDON = ...
local PATH = "Interface\\AddOns\\"..ADDON.."\\SoundFiles\\"
local M = LibStub("LibSharedMedia-3.0")

M:Register(TYPE, "A Sound",       PATH.."filename_a.ogg")
M:Register(TYPE, "Another Sound", PATH.."filename_b.ogg")
M:Register(TYPE, "Weird Sound",   PATH.."weird.ogg")
-- more sounds here
That's all you need.

Edit:
Actually it looks like you're already doing this, based on the first code you posted. I don't know what that second block is for, and it should be throwing an error anyway; you can just get rid of it.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote