|
|
|
@ -263,12 +263,17 @@ func updateStatus() {
|
|
|
|
|
statusLock.Lock() |
|
|
|
|
defer statusLock.Unlock() |
|
|
|
|
|
|
|
|
|
var sampleRate beep.SampleRate |
|
|
|
|
var p time.Duration |
|
|
|
|
var l time.Duration |
|
|
|
|
var v float64 |
|
|
|
|
var paused bool |
|
|
|
|
var silent bool |
|
|
|
|
var ( |
|
|
|
|
sampleRate beep.SampleRate |
|
|
|
|
p time.Duration |
|
|
|
|
l time.Duration |
|
|
|
|
v float64 |
|
|
|
|
paused bool |
|
|
|
|
silent bool |
|
|
|
|
|
|
|
|
|
progressFormatted string |
|
|
|
|
durationFormatted string |
|
|
|
|
) |
|
|
|
|
if playingStreamer != nil && volume != nil && ctrl != nil { |
|
|
|
|
audioLock.Lock() |
|
|
|
|
speaker.Lock() |
|
|
|
@ -281,6 +286,9 @@ func updateStatus() {
|
|
|
|
|
speaker.Unlock() |
|
|
|
|
audioLock.Unlock() |
|
|
|
|
|
|
|
|
|
progressFormatted = formatDuration(p) |
|
|
|
|
durationFormatted = formatDuration(l) |
|
|
|
|
|
|
|
|
|
statusBuffer.Reset() |
|
|
|
|
|
|
|
|
|
if paused { |
|
|
|
@ -316,6 +324,26 @@ func updateStatus() {
|
|
|
|
|
statusBuffer.WriteString(topStatusExtra) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
topstatusbuf.SetText(statusBuffer.String()) |
|
|
|
|
} else { |
|
|
|
|
v = startingVolumeLevel |
|
|
|
|
silent = startingVolumeSilent |
|
|
|
|
|
|
|
|
|
progressFormatted = "--:--" |
|
|
|
|
durationFormatted = "--:--" |
|
|
|
|
|
|
|
|
|
statusBuffer.Reset() |
|
|
|
|
|
|
|
|
|
trackInfo := fmt.Sprintf("ditty %s", version) |
|
|
|
|
|
|
|
|
|
topStatusMaxLength := screenWidth - 2 |
|
|
|
|
padding := (topStatusMaxLength - runewidth.StringWidth(trackInfo)) + 1 |
|
|
|
|
for i := 0; i < padding; i++ { |
|
|
|
|
statusBuffer.WriteRune(' ') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
statusBuffer.WriteString(trackInfo) |
|
|
|
|
|
|
|
|
|
topstatusbuf.SetText(statusBuffer.String()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -339,7 +367,7 @@ func updateStatus() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bottomStatus := fmt.Sprintf("%s %s", formatDuration(l), statusBuffer.String()) |
|
|
|
|
bottomStatus := fmt.Sprintf("%s %s", durationFormatted, statusBuffer.String()) |
|
|
|
|
statusBuffer.Reset() |
|
|
|
|
|
|
|
|
|
var progressIndicator string |
|
|
|
@ -372,7 +400,7 @@ func updateStatus() {
|
|
|
|
|
volumeStart = seekEnd + len(formatDuration(l)) + 4 |
|
|
|
|
volumeEnd = screenWidth - 2 |
|
|
|
|
|
|
|
|
|
bottomstatusbuf.SetText(" " + formatDuration(p) + " " + statusBuffer.String() + " " + bottomStatus) |
|
|
|
|
bottomstatusbuf.SetText(" " + progressFormatted + " " + statusBuffer.String() + " " + bottomStatus) |
|
|
|
|
statusBuffer.Reset() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|