func (t *Sound) Play(loops int) { t.channel = int(C.Mix_PlayChannelTimed(C.int(-1), t.chunk, C.int(loops), C.int(-1))) if t.channel == -1 { panic(fmt.Sprintf("Unable to play Sound file (%v): %v", t.name, util.GetMixError())) } t.SetVolume(GDefaultVolume) }
func (chunk *Chunk) PlayTimed(channel, loops, ticks int) bool { _channel := (C.int)(channel) _chunk := (*C.Mix_Chunk)(unsafe.Pointer(chunk)) _loops := (C.int)(loops) _ticks := (C.int)(ticks) return int(C.Mix_PlayChannelTimed(_channel, _chunk, _loops, _ticks)) == 0 }
func (chunk *Chunk) PlayChannel(channel, loops int) (channel_ int, err error) { _channel := (C.int)(channel) _chunk := (*C.Mix_Chunk)(unsafe.Pointer(chunk)) _loops := (C.int)(loops) channel_ = int(C.Mix_PlayChannelTimed(_channel, _chunk, _loops, -1)) if channel_ == -1 { err = sdl.GetError() } return }
//If the sample is long enough and has enough loops then the sample will stop after ticks milliseconds. //Otherwise this function is the same as chunk.PlayChannel() //Returns: the channel the sample is played on. On any errors, -1 is returned func (c *Chunk) PlayChannelTimed(channel, loops, ticks int) int { return int(C.Mix_PlayChannelTimed(C.int(channel), c.cchunk, C.int(loops), C.int(ticks))) }
func (c *Chunk) PlayChannel(channel, loops int) int { return int(C.Mix_PlayChannelTimed(C.int(channel), c.cchunk, C.int(loops), -1)) }
// Play an audio chunk on a specific channel. // If the specified channel is -1, play on the first free channel. // If 'loops' is greater than zero, loop the sound that many times. // If 'loops' is -1, loop inifinitely (~65000 times). // Returns which channel was used to play the sound. // The the sound is played at most 'ticks' milliseconds. func PlayChannelTimed(channel int , chunk * C.Mix_Chunk, loops, ticks int) (int) { return int(C.Mix_PlayChannelTimed(C.int(channel), chunk, C.int(loops), C.int(ticks))) }