Skip to content

Commit

Permalink
timing-infos for webfrontend javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
kventil committed Mar 18, 2013
1 parent 04c4580 commit a12498a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@ def setSong(spotify_uri)
end
out
end

#returns the current playing song
#nothing if the time betweet set is > than set+songlength
get '*/current_song' do
now = Time.now.to_i
if $current_song.set + $current_song.length > now
"#{$current_song.to_s} - #{now - $current_song.set} / #{$current_song.length}"
else
"empty"
end
end

get '*/remaining' do
now = Time.now.to_i
remaining = ($current_song.set + $current_song.length) - now
unless 0 > remaining
"#{remaining.to_i}"
else
"0"
end
end

0 comments on commit a12498a

Please sign in to comment.