Pawel
April 6, 2020, 9:07am
1
When I play a sound and it ends the script should receive “sound_done” message according to API, but there is no such message.
Repro:
Empty Project.zip (4.7 MB)
function init(self)
--sound.play("#music", { gain = 1.0 })
msg.post("#music", "play_sound")
end
function on_message(self, message_id, message, sender)
print("ALL MSG", message_id)
if message_id == hash("sound_done") then
print("DONE")
end
end
and not even a single message is received
Klear
April 6, 2020, 9:08am
2
I ran across this recently. You have to specify play_id for the message to be sent.
msg.post("#music", "play_sound", {play_id = 1})
3 Likes
Pawel
April 6, 2020, 9:10am
3
Thank you! This instantly solves the problem!
2 minutes support
1 Like
britzl
April 6, 2020, 1:01pm
4
There is also sound.play() which can take a callback that will be invoked when the sound has finished playing.
2 Likes
Pawel
April 6, 2020, 4:38pm
5
This is even more useful for me! Thanks! I should more frequently check API