mirror of
https://github.com/bloeys/wavy.git
synced 2025-12-29 09:28:19 +00:00
Improve PlaySync
This commit is contained in:
6
wavy.go
6
wavy.go
@ -81,15 +81,19 @@ type Sound struct {
|
||||
Info SoundInfo
|
||||
}
|
||||
|
||||
//PlayAsync plays the sound in the background and returns
|
||||
func (s *Sound) PlayAsync() {
|
||||
s.Player.Play()
|
||||
}
|
||||
|
||||
//PlaySync plays the sound (if its not already playing) and waits for it to finish before returning.
|
||||
func (s *Sound) PlaySync() {
|
||||
|
||||
if !s.Player.IsPlaying() {
|
||||
s.Player.Play()
|
||||
time.Sleep(s.TotalTime())
|
||||
}
|
||||
|
||||
time.Sleep(s.RemainingTime())
|
||||
//Should never run, but just in case TotalTimeMS was a bit inaccurate
|
||||
for s.Player.IsPlaying() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user