use a zero waveform image with single horizontal line when none exists
This commit is contained in:
@@ -190,6 +190,15 @@ func (p *PlaybackManager) handleWaveformImageSongChange(item mediaprovider.Media
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if item == nil || item.Metadata().Type != mediaprovider.MediaItemTypeTrack {
|
||||
// set a zero waveform image when we're not playing anything
|
||||
// or playing a media type we can't derive a waveform from (e.g. radio)
|
||||
img := NewWaveformImage()
|
||||
for _, cb := range p.onWaveformImgUpdate {
|
||||
cb(img)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PlaybackManager) ScanRemotePlayers(ctx context.Context, fastScan bool) {
|
||||
|
||||
@@ -28,7 +28,16 @@ type WaveformImageGenerator struct {
|
||||
type WaveformImage = image.NRGBA
|
||||
|
||||
func NewWaveformImage() *WaveformImage {
|
||||
return image.NewNRGBA(image.Rect(0, 0, 1024, 48))
|
||||
img := image.NewNRGBA(image.Rect(0, 0, 1024, 48))
|
||||
centerTop := img.Rect.Dy() / 2 // 24
|
||||
centerBottom := centerTop - 1 // 23
|
||||
|
||||
// color in center line
|
||||
for x := 0; x < img.Bounds().Dx(); x++ {
|
||||
setPixel(img, x, centerTop, color.NRGBA{R: 255, G: 255, B: 255, A: 255})
|
||||
setPixel(img, x, centerBottom, color.NRGBA{R: 255, G: 255, B: 255, A: 255})
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
type WaveformImageJob struct {
|
||||
|
||||
Reference in New Issue
Block a user