aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.go b/main.go
index a4cb153..b5dbc1b 100644
--- a/main.go
+++ b/main.go
@@ -157,7 +157,13 @@ func µsToString(µs int64) string {
func (p *Player) Position() string {
// 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)
if length == "" {
return ""
@@ -436,7 +442,6 @@ func main() {
os.Remove(SOCK)
os.Exit(1)
}()
- defer os.Remove(SOCK)
if err != nil {
log.Fatalln("Couldn't establish socket connection at", SOCK)
}