Class: DmCloud::Streaming
- Inherits:
-
Object
- Object
- DmCloud::Streaming
- Defined in:
- lib/dm_cloud/streaming.rb
Constant Summary collapse
- DIRECT_STREAM =
Default URL to get embed content ou direct url
"[PROTOCOL]://cdn.dmcloud.net/route/[USER_ID]/[MEDIA_ID]/[ASSET_NAME].[ASSET_EXTENSION]".freeze
- THUMBNAIL_STREAM =
"[PROTOCOL]://static-ssl.dmcloud.net/[USER_ID]/[MEDIA_ID]/[ASSET_NAME].[ASSET_EXTENSION]".freeze
- EMBED_STREAM =
"[PROTOCOL]://api.dmcloud.net/embed/[USER_ID]/[MEDIA_ID]".freeze
- EMBED_IFRAME =
'<iframe width="[WIDTH]" height="[HEIGHT]" frameborder="0" scrolling="no" src="[EMBED_URL]"></iframe>'.freeze
Class Method Summary collapse
-
.embed(media_id, options = {}, security = {}) ⇒ Object
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=“api.DmCloud.net/embed/<user_id>/<media_id>?auth=<auth_token>&skin=<skin_id>”></iframe>.
- .thumbnail(media_id, asset_name, asset_extension = nil, security = {}) ⇒ Object
-
.url(media_id, asset_name, asset_extension = nil, security = {}) ⇒ Object
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 cdn.DmCloud.net/route/<user_id>/<media_id>/<asset_name>.<asset_extension>?auth=<auth_token>.
Class Method Details
.embed(media_id, options = {}, security = {}) ⇒ Object
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>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dm_cloud/streaming.rb', line 26 def self.(media_id, = {}, security = {}) raise StandardError, "missing :media_id in params" unless media_id skin_id = [:skin_id] ? [:skin_id] : 'modern1' width = [:width] ? [:width].to_s : '848' height = [:height] ? [: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 = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 = {}) ⇒ Object
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>
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# 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 |