mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
Send time data back to client.
This commit is contained in:
parent
e5347354ee
commit
d9443389db
@ -38,9 +38,15 @@ class MPDClient < Sinatra::Base
|
|||||||
settings.connections.each { |out| out << "data: #{response}\n\n" }
|
settings.connections.each { |out| out << "data: #{response}\n\n" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.send_time(elapsed, total)
|
||||||
|
response = JSON({ type: 'time', data: { elapsed: elapsed, total: total } })
|
||||||
|
settings.connections.each { |out| out << "data: #{response}\n\n" }
|
||||||
|
end
|
||||||
|
|
||||||
MPDConnection.mpd.on(:song) { |song| send_status }
|
MPDConnection.mpd.on(:song) { |song| send_status }
|
||||||
MPDConnection.mpd.on(:state) { |state| send_status }
|
MPDConnection.mpd.on(:state) { |state| send_status }
|
||||||
MPDConnection.mpd.on(:playlist) { |playlist| send_queue }
|
MPDConnection.mpd.on(:playlist) { |playlist| send_queue }
|
||||||
|
MPDConnection.mpd.on(:time) { |elapsed, total| send_time(elapsed, total) }
|
||||||
|
|
||||||
namespace '/api' do
|
namespace '/api' do
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user