Skip to content

Commit

Permalink
adding volume method
Browse files Browse the repository at this point in the history
git-svn-id: svn://rubyforge.org/var/svn/raop/trunk@6 55bd698d-9d04-498c-8937-980560813b27
  • Loading branch information
aaronp committed Jun 14, 2007
1 parent ab7e227 commit 222d62d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/raop/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def connect
response = @rtsp_client.request(params)
end

def volume=(volume)
volume = 0 + volume if volume < 0
raise ArgumentError if volume < 0 || volume > 144
params = Net::RTSP::SetParameter.new(@session_id,
{ :volume => "-#{volume}".to_i }
)
response = @rtsp_client.request(params)
end

def play(file)
while data = file.read(4096 * 2 * 2)
send_sample(self.class.encode_alac(data))
Expand Down
3 changes: 2 additions & 1 deletion lib/raop/rtsp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def write_header(sock, client_id, cseq)
end

def write_body(sock)
#$stdout.write(@body) if @body
sock.write(@body) if @body
end
end
Expand All @@ -135,7 +136,7 @@ def initialize(session_id, opts = {})
self['Content-Type'] = 'text/parameters'
buf = ''
opts.each do |k,v|
buf << "#{k}: #{sprintf('%0.6f', v)}"
buf << "#{k}: #{sprintf('%0.6f', v)}\r\n"
end
@body = buf if buf.length > 0
end
Expand Down

0 comments on commit 222d62d

Please sign in to comment.