Skip to content

Commit

Permalink
Fix: set current need clear status
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Oct 7, 2023
1 parent 8e0a49d commit ade71a0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion room/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *Current) SetMovie(movie MovieInfo) {
defer c.lock.Unlock()

c.movie = movie
c.status.Seek = 0
c.setSeek(0, 0)
}

func (c *Current) Status() Status {
Expand Down Expand Up @@ -101,3 +101,19 @@ func (c *Current) SetSeekRate(seek, rate, timeDiff float64) Status {
c.status.lastUpdateTime = time.Now()
return c.status
}

func (c *Current) SetSeek(seek, timeDiff float64) Status {
c.lock.Lock()
defer c.lock.Unlock()
return c.setSeek(seek, timeDiff)
}

func (c *Current) setSeek(seek, timeDiff float64) Status {
if c.status.Playing {
c.status.Seek = seek + (timeDiff * c.status.Rate)
} else {
c.status.Seek = seek
}
c.status.lastUpdateTime = time.Now()
return c.status
}

0 comments on commit ade71a0

Please sign in to comment.