lib/mpd: add the time field to SongInfo
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 23 Aug 2013 12:21:16 +0000 (08:21 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sat, 24 Aug 2013 02:06:18 +0000 (22:06 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/mpd.nit

index ced7e17..9ed7784 100644 (file)
@@ -150,6 +150,7 @@ class MPDConnection
                var album: nullable String = null
                var artist: nullable String = null
                var title: nullable String = null
+               var time: nullable Int = null
 
                socket.write("currentsong\n")
                var rep = socket.read
@@ -165,12 +166,15 @@ class MPDConnection
                                        artist = rest
                                else if key == "title:" then
                                        title = rest
+                               else if key == "time:" then
+                                       time = rest.to_i
                                end
                        end
                end
 
-               if album != null and artist != null and title != null then
-                       return new SongInfo(album, artist, title)
+               if album != null and artist != null and
+                       title != null and time != null then
+                       return new SongInfo(album, artist, title, time)
                else
                        return null
                end
@@ -182,6 +186,7 @@ class SongInfo
        var album: String
        var artist: String
        var title: String
+       var time: Int
 end
 
 # MPD server status