fix crash when tracklength not available

This commit is contained in:
Harvey Tindall 2020-09-11 21:24:11 +01:00
parent 8343e713fe
commit 018e3ce34e
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
2 changed files with 7 additions and 2 deletions

View File

@ -157,7 +157,13 @@ func µsToString(µs int64) string {
func (p *Player) Position() string { func (p *Player) Position() string {
// position is in microseconds so we prob need int64 to be safe // position is in microseconds so we prob need int64 to be safe
l := p.metadata["mpris:length"].Value().(int64) v := p.metadata["mpris:length"].Value()
var l int64
if v != nil {
l = v.(int64)
} else {
return ""
}
length := µsToString(l) length := µsToString(l)
if length == "" { if length == "" {
return "" return ""
@ -436,7 +442,6 @@ func main() {
os.Remove(SOCK) os.Remove(SOCK)
os.Exit(1) os.Exit(1)
}() }()
defer os.Remove(SOCK)
if err != nil { if err != nil {
log.Fatalln("Couldn't establish socket connection at", SOCK) log.Fatalln("Couldn't establish socket connection at", SOCK)
} }

Binary file not shown.