Seek seeks the position with the given offset. Seek returns error when seeking the source stream returns error.
(offset time.Duration)
| 251 | // |
| 252 | // Seek returns error when seeking the source stream returns error. |
| 253 | func (p *Player) Seek(offset time.Duration) error { |
| 254 | o := int64(offset) * bytesPerSample * channelNum * int64(p.sampleRate) / int64(time.Second) |
| 255 | o &= mask |
| 256 | select { |
| 257 | case p.seekCh <- seekArgs{o, io.SeekStart}: |
| 258 | return <-p.seekedCh |
| 259 | case <-p.readLoopEndedCh: |
| 260 | return fmt.Errorf("audio: the player is already closed") |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | // Pause pauses the playing. |
| 265 | func (p *Player) Pause() { |
no outgoing calls