Class: Cloudkey::Media
Constant Summary collapse
- CDN_URL =
'http://cdn.dmcloud.net'
- STATIC_URL =
'http://static.dmcloud.net'
- PROTOCOLS =
%w(hls rtmp hps http)
- ProtocolError =
Class.new(Exception)
Instance Method Summary collapse
- #embedded_url(id, security_level = SecurityPolicy.new) ⇒ Object
- #stream_url(id, asset_name = "mp4_h264_aac", security_level = SecurityPolicy.new, opts = {}) ⇒ Object
Methods inherited from Client
Constructor Details
This class inherits a constructor from Cloudkey::Client
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cloudkey::Client
Instance Method Details
#embedded_url(id, security_level = SecurityPolicy.new) ⇒ Object
9 10 11 12 |
# File 'lib/cloudkey/media.rb', line 9 def id, security_level = SecurityPolicy.new url = "#{@api.base_url}/embed/#{@api.user_id}/#{id}" API.sign_url url, @api.key, security_level end |
#stream_url(id, asset_name = "mp4_h264_aac", security_level = SecurityPolicy.new, opts = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cloudkey/media.rb', line 14 def stream_url id, asset_name="mp4_h264_aac", security_level=SecurityPolicy.new, opts={} opts = normalize_opts(opts) # Switch to static cdn for thumbnails if asset_name.match(/^jpeg_thumbnail/) opts[:cdn_url] = STATIC_URL ts = "-#{opts[:expires_in]}" if opts[:expires_in] url = "#{opts[:cdn_url]}/#{@api.user_id}/#{id}/#{asset_name}/#{ts}/#{version}" return url end extension = asset_name.split('_')[0] extension = "f4m" if extension == 'f4f' url = "#{opts[:cdn_url]}" url << "/route" url << "/#{opts[:protocol]}" if opts[:protocol] != '' url << "/#{@api.user_id}/#{id}/#{asset_name}#{opts[:version]}.#{extension}" API.sign_url url, @api.key, security_level end |