Sound.Ended

This event would fire when a Sound has stopped on its own. Currently, the only way to detect it is if you compare its TimeLength and TimePosition values together, which is a huge hassle.

technically you can do this by using sound.DidLoop
v put in command bar in a new place

[code]s = Instance.new(‘Sound’,workspace)
s.SoundId = ‘rbxassetid://137563489’
s.Looped = true

s.DidLoop:connect(function(id,times)
print(id,times)
s:Stop()
end)
s:Play()

game.Debris:AddItem(s,5)
[/code]

[quote] technically you can do this by using sound.DidLoop
v put in command bar in a new place

[code]s = Instance.new(‘Sound’,workspace)
s.SoundId = ‘rbxassetid://137563489’
s.Looped = true

s.DidLoop:connect(function(id,times)
print(id,times)
s:Stop()
end)
s:Play()

game.Debris:AddItem(s,5)
[/code] [/quote]

Yes, but it would be nice to have an actual method of doing this, not some odd workaround.

How is it an odd workaround o:

You want an event to fire when it stops playing
it does that, lol

Edit: Oh, it’s not immediately intuitive. You’re right, it should just be an added event. Cuz this requires looping to be set to true, (which doesn’t matter, because it Stop()s it at the end of a loop) but it’s just ugly messing with a property that doesn’t need to be messed with.

Edit2: One might think sound.Stopped() would work automatically, but it only fires when Stop() is called manually. Weird.

Oh well, at least I fixed your error of “Currently, the only way to detect it is if you compare its TimeLength and TimePosition values together” because my way is the second way to detect it. <:

Such hacky workarounds are needed for this atm.

DidLoop is not a valid workaround when I tried as it only fires on looped sounds. If you make your sound a loop and stop it after DidLoop hits true then you have a .2 or so second delay at the end.

My workaround is checking TimePosition==0 on a loop. Then waiting about half a second. That makes the next sound play immediately. That’s what the Hex announcer does.

I was really disappointed when all of the new events for sounds came out and this wasn’t in it. Sound.Stopped should have this behavior.

" If you make your sound a loop and stop it after DidLoop hits true then you have a .2 or so second delay at the end."

What do you mean by a 0.2 delay? The event is firing instantly, stopping instantly, and playing the next sound instantly without a delay. Unless you mean the regular 0.15 delay between every MP3 at each start, which is not the current issue at hand? [use .ogg now to get seamless loops at the cost of slightly less compression, if that is an issue btw]

[spoiler]=code][code] s = Instance.new(‘Sound’,workspace)
s.SoundId = ‘rbxassetid://146750669’
s.Looped = true

s2 = Instance.new(‘Sound’,workspace)
s2.SoundId = ‘rbxassetid://198099744’
s2.Looped = true

s.DidLoop:connect(function(id,times)
s:Stop()
print’endloop’
s2:Play()
end)
s:Play()[/code][/spoiler]

Edit:
“My workaround is checking TimePosition==0 on a loop. Then waiting about half a second. That makes the next sound play immediately.”
That would make it loop on at least a 0.5 second delay, not immediate .-. Good for an announcer so it’s more natural, but not for immediately showing the exact frame the sound stops in


However, my posts are all fluff at this point.

Looping in a coroutine at 30 or 60 fps to check timeposition
vs.
Using the DidLoop event

are both unintuitive and messy, q_q

[quote] " If you make your sound a loop and stop it after DidLoop hits true then you have a .2 or so second delay at the end."

What do you mean by a 0.2 delay? The event is firing instantly, stopping instantly, and playing the next sound instantly without a delay. Unless you mean the regular 0.15 delay between every MP3 at each start, which is not the current issue at hand? [use .ogg now to get seamless loops at the cost of slightly less compression, if that is an issue btw]

[spoiler]=code][code] s = Instance.new(‘Sound’,workspace)
s.SoundId = ‘rbxassetid://146750669’
s.Looped = true

s2 = Instance.new(‘Sound’,workspace)
s2.SoundId = ‘rbxassetid://198099744’
s2.Looped = true

s.DidLoop:connect(function(id,times)
s:Stop()
print’endloop’
s2:Play()
end)
s:Play()[/code][/spoiler]

Edit:
“My workaround is checking TimePosition==0 on a loop. Then waiting about half a second. That makes the next sound play immediately.”
That would make it loop on at least a 0.5 second delay, not immediate .-. Good for an announcer so it’s more natural, but not for immediately showing the exact frame the sound stops in


However, my posts are all fluff at this point.

Looping in a coroutine at 30 or 60 fps to check timeposition
vs.
Using the DidLoop event

are both unintuitive and messy, q_q [/quote]

What I am saying is.

1 - I looped the sound
2 - I checked on a loop for DidLoop (stepped)
3 - When DidLoop hit true I stopped the sound

The result: The sound played itself then played itself partially again before stopping. Ie:

hello he…stop

All around not a satisfactory solution. If you’ve got it to work though then maybe they’ve improved it. The best solution I found was the one I described above.

About .5 led to it playing instantaneously as soon as the last sound ended. Less than that and it overlapped a little. The problem is your overestimating just how reliable those properties are.

I spent 6 hours last night trying to get sounds to play after the current one ends. Came up with this less than ideal solution:

spawn(function() while wait() do -- using a while loop to continue checking after the last sound stopped repeat wait() until workspace.GameSound.TimePosition > 0 --wait until it starts repeat wait() until workspace.GameSound.TimePosition == 0 --wait until it ends (Looped can't be set true) --sound has ended end end)

Oh and this must ran on the client. No events, TimePosition or TimeLength are written to on the server :frowning: