// Seek moves replay forward/backward by the given duration.
Seek moves replay forward/backward by the given duration.
// Seek moves replay forward / backward by the given duration .
func (rep *Replay) Seek(d time.Duration) {
	rep.decodeNext()
	if len(rep.frames) == 0 {
		return
	}
	n := rep.fidx - 1
	if n < 0 || n >= len(rep.frames) {
		return
	}
	var t time.Time
	t = rep.frames[n].Time.Add(d)
	if d > 0 {
		for t.After(rep.frames[rep.fidx-1].Time) {
			rep.decodeNext()
			if rep.fidx >= len(rep.frames) {
				break
			}
			rep.fidx++
			rep.next()
		}
	} else {
		for t.Before(rep.frames[rep.fidx-1].Time) {
			if rep.fidx <= 1 {
				break
			}
			rep.fidx--
			rep.previous()
		}
	}
	rep.dirty = true
}
func ( rep * Replay ) Seek ( d time . Duration ) { rep . decodeNext ( ) if len ( rep . frames ) == 0 { return } n := rep . fidx - 1 if n < 0 || n >= len ( rep . frames ) { return } var t time . Time t = rep . frames [ n ] . Time . Add ( d ) if d > 0 { for t . After ( rep . frames [ rep . fidx - 1 ] . Time ) { rep . decodeNext ( ) if rep . fidx >= len ( rep . frames ) { break } rep . fidx ++ rep . next ( ) } } else { for t . Before ( rep . frames [ rep . fidx - 1 ] . Time ) { if rep . fidx <= 1 { break } rep . fidx -- rep . previous ( ) } } rep . dirty = true }
Seek moves replay forward/backward by the given duration.
Seek moves replay forward / backward by the given duration .