Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions lib/sonos/endpoint/a_v_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ def has_music?
# Get information about the state the player is in.
def get_player_state
response = send_transport_message('GetTransportInfo')
body = response.body[:get_transport_info_response]

{
status: body[:current_transport_status],
state: body[:current_transport_state],
speed: body[:current_speed],
}
if response
body = response.body[:get_transport_info_response]
{
status: body[:current_transport_status],
state: body[:current_transport_state],
speed: body[:current_speed],
}
end
end

# Returns true if the player is not in a paused or stopped state
Expand Down Expand Up @@ -103,7 +104,7 @@ def select_track(index)

# Clear the queue
def clear_queue
parse_response parse_response send_transport_message('RemoveAllTracksFromQueue')
parse_response send_transport_message('RemoveAllTracksFromQueue')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been merged as part of #35

end

# Save queue
Expand Down Expand Up @@ -237,12 +238,16 @@ def set_av_transport_uri(uri)
end

def transport_client
@transport_client ||= Savon.client endpoint: "http://#{self.group_master.ip}:#{Sonos::PORT}#{TRANSPORT_ENDPOINT}", namespace: Sonos::NAMESPACE, log: Sonos.logging_enabled
if self.group_master
@transport_client ||= Savon.client endpoint: "http://#{self.group_master.ip}:#{Sonos::PORT}#{TRANSPORT_ENDPOINT}", namespace: Sonos::NAMESPACE, log: Sonos.logging_enabled
end
end

def send_transport_message(name, part = '<Speed>1</Speed>')
action = "#{TRANSPORT_XMLNS}##{name}"
message = %Q{<u:#{name} xmlns:u="#{TRANSPORT_XMLNS}"><InstanceID>0</InstanceID>#{part}</u:#{name}>}
transport_client.call(name, soap_action: action, message: message)
if transport_client
transport_client.call(name, soap_action: action, message: message)
end
end
end
5 changes: 5 additions & 0 deletions lib/sonos/features/voiceover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def voiceover!(uri, vol = nil)
result.merge({duration: (Time.now - start_time )})
end

def resume_queue
puts "resume queue"
play uid.gsub('uuid', 'x-rincon-queue') + '#0'
end

protected

def with_isolated_state
Expand Down