Permalink
Browse files

support for getting recording urls in different formats and streaming…

… the binary data
  • Loading branch information...
andrewmbenton committed Aug 26, 2011
1 parent 55ca9cf commit fce44fab9af3937eb9f6e4619a82946f43288731
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/twilio-ruby/rest/recordings.rb
@@ -6,6 +6,26 @@ class Recording < InstanceResource
def initialize(uri, client, params={})
super uri, client, params
resource :transcriptions
+ # grab a reference to the client's connection object for streaming
+ @connection = @client.instance_variable_get :@connection
+ end
+
+ def wav
+ scheme = @connection.use_ssl ? 'https' : 'http'
+ "#{scheme}://#{@connection.address}#{@uri}.wav"
+ end
+
+ def wav!(&block)
+ @connection.request_get @uri, &block
+ end
+
+ def mp3
+ scheme = @connection.use_ssl ? 'https' : 'http'
+ "#{scheme}://#{@connection.address}#{@uri}.mp3"
+ end
+
+ def mp3!(&block)
+ @connection.request_get "#{@uri}.mp3", &block
end
end
end

0 comments on commit fce44fa

Please sign in to comment.