ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Detect when SoundPlay complete it's task (https://www.esoui.com/forums/showthread.php?t=7411)

Hell4Ge 10/14/17 04:38 PM

Detect when SoundPlay complete it's task
 
This code represents the problem that I am facing now:

SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, 1)
PlaySound(SOUNDS.EMPEROR_CORONATED_DAGGERFALL)
SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, 0)

The sound will be played, but I won't be able to hear it as the 3rd line executes instantly

Any solution for this?

Edit: I am looking now at
http://esoapi.uesp.net/current/src/l...layer.lua.html

Dolgubon 10/14/17 04:55 PM

I can't seem to find a function for sound length or a sound complete event, so what you can do is first test how long the sound takes to play, and then use zo_callLater(function() changeSetting end, delayInMilliseconds)

Hell4Ge 10/14/17 07:01 PM

I have found a solution

function onSoundFinishedTurnOffBackgroundAudio()
SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, 0)
end

local alertSound = ZO_QueuedSoundPlayer:New()
alertSound:SetFinishedAllSoundsCallback(onSoundFinishedTurnOffBackgroundAudio)
alertSound:PlaySound(SOUNDS.EMPEROR_CORONATED_DAGGERFALL, 3000)


All times are GMT -6. The time now is 02:04 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI