Skip to content

Commit

Permalink
Better looking player bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Depado committed Nov 14, 2020
1 parent c6810fd commit 4e92d9a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions player/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ func fmtDuration(d time.Duration) string {
}

func (p *Player) GeneratePlayerString(dur time.Duration) string {
player := "--------------------"
in := "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
player := []rune(in)
pb := p.stream.PlaybackPosition()
pos := int(pb*100/dur) * len(player) / 100
play := player[:pos] + "●" + player[pos:]
return fmt.Sprintf("%s %s %s", fmtDuration(pb), play, fmtDuration(dur))
if pos >= len(player) {
pos = len(player) - 1
}
player[pos] = '●'

return fmt.Sprintf("%s %s %s", fmtDuration(pb), string(player), fmtDuration(dur))
}

func (p *Player) GenerateNowPlayingEmbed(short bool) *discordgo.MessageEmbed {
Expand Down

0 comments on commit 4e92d9a

Please sign in to comment.