class DmCloud::Streaming
Constants
- DIRECT_STREAM
Default URL to get embed content ou direct url
- EMBED_IFRAME
- EMBED_STREAM
- THUMBNAIL_STREAM
Public Class Methods
embed(media_id, options = {}, security = {})
click to toggle source
Get embeded player Params :
media_id: this is the id of the media (eg: 4c922386dede830447000009) options: skin_id: (optional) the id of the custom skin for the video player width: (optional) the width for the video player frame height: (optional) the height for the video player frame
Result :
return a string which contain the signed url like <iframe width="848" height="480" frameborder="0" scrolling="no" src="http://api.DmCloud.net/embed/<user_id>/<media_id>?auth=<auth_token>&skin=<skin_id>"></iframe>
# File lib/dm_cloud/streaming.rb, line 26 def self.embed(media_id, options = {}, security = {}) raise StandardError, "missing :media_id in params" unless media_id skin_id = options[:skin_id] ? options[:skin_id] : 'modern1' width = options[:width] ? options[:width].to_s : '848' height = options[:height] ? options[:height].to_s : '480' stream = EMBED_STREAM.dup stream.gsub!('[PROTOCOL]', DmCloud.config[:protocol]) stream.gsub!('[USER_ID]', DmCloud.config[:user_key]) stream.gsub!('[MEDIA_ID]', media_id) signed_url = DmCloud::Signing.sign(stream, security) signed_url = stream + "?auth=#{signed_url}" frame = EMBED_IFRAME.dup frame.gsub!('[WIDTH]', width) frame.gsub!('[HEIGHT]', height) frame.gsub!('[EMBED_URL]', signed_url) frame.html_safe end
thumbnail(media_id, asset_name, asset_extension = nil, security = {})
click to toggle source
# File lib/dm_cloud/streaming.rb, line 49 def self.thumbnail(media_id, asset_name, asset_extension = nil, security = {}) raise StandardError, "missing :media_id in params" unless media_id raise StandardError, "missing :asset_name in params" unless asset_name asset_extension = asset_name.split('_').first unless asset_extension stream = THUMBNAIL_STREAM.dup stream.gsub!('[PROTOCOL]', DmCloud.config[:protocol]) stream.gsub!('[USER_ID]', DmCloud.config[:user_key]) stream.gsub!('[MEDIA_ID]', media_id) stream.gsub!('[ASSET_NAME]', asset_name) stream.gsub!('[ASSET_EXTENSION]', asset_extension) stream += '?auth=[AUTH_TOKEN]'.gsub!('[AUTH_TOKEN]', DmCloud::Signing.sign(stream, security)) stream end
url(media_id, asset_name, asset_extension = nil, security = {})
click to toggle source
Get media url for direct link to the file on DailyMotion Cloud Params :
media_id: this is the id of the media (eg: 4c922386dede830447000009) asset_name: the name of the asset you want to stream (eg: mp4_h264_aac) asset_extension: the extension of the asset, most of the time it is the first part of the asset name (eg: mp4)
Result :
return a string which contain the signed url like http://cdn.DmCloud.net/route/<user_id>/<media_id>/<asset_name>.<asset_extension>?auth=<auth_token>
# File lib/dm_cloud/streaming.rb, line 73 def self.url(media_id, asset_name, asset_extension = nil, security = {}) raise StandardError, "missing :media_id in params" unless media_id raise StandardError, "missing :asset_name in params" unless asset_name asset_extension = asset_name.split('_').first unless asset_extension stream = DIRECT_STREAM.dup stream.gsub!('[PROTOCOL]', DmCloud.config[:protocol]) stream.gsub!('[USER_ID]', DmCloud.config[:user_key]) stream.gsub!('[MEDIA_ID]', media_id) stream.gsub!('[ASSET_NAME]', asset_name) stream.gsub!('[ASSET_EXTENSION]', asset_extension) stream += '?auth=[AUTH_TOKEN]'.gsub!('[AUTH_TOKEN]', DmCloud::Signing.sign(stream, security)) stream end