mpd :: MPDConnection :: current_song
# Get information on the currently playing song on the MPD server
fun current_song: nullable SongInfo
do
if socket == null then connect
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(1024)
for l in rep.split_with("\n") do
var words = l.split_with(" ")
if words.length > 1 then
var key = words[0].to_lower
var first_space = l.chars.index_of(' ')
var rest = l.substring_from(first_space+1)
if key == "album:" then
album = rest
else if key == "artist:" then
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 and time != null then
return new SongInfo(album, artist, title, time)
else
return null
end
end
lib/mpd/mpd.nit:154,2--190,4