View Single Post
04-15-19, 11:18 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Munkdev I believe posted this to stop sounds playing (if it was someone else, apologies and please let me know). Should also work for PlaySoundFile():

Lua Code:
  1. local mutex = false -- need this so it doesn't recurse when PlaySound is called from within
  2. hooksecurefunc('PlaySound', function(id)
  3.     if mutex then return end -- we called this time, just return
  4.     mutex = true -- flag mutex
  5.     -- play another sound to figure out the ID.
  6.     -- can't play the same sound because it's occupied by another handle.
  7.     local played, handle = PlaySound(id+1) -- just use the ID+1 to guarantee it's different
  8.     mutex = false -- unflag mutex
  9.     if played then
  10.         StopSound(handle-1) -- stop the sound you wanted to stop in the first place
  11.         StopSound(handle) -- stop your dummy sound
  12.     end
  13. end)
  14.  
  15. --  Stop playsound from a specific function
  16. hooksecurefunc("BNToastFrame_Show", function()
  17.     local played, handle = PlaySound(SOUNDKIT.AMB_GLUESCREEN_WORGEN)
  18.     StopSound(handle-1)
  19.     StopSound(handle)
  20. end)

There's no pause/restart functions.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote