Method: DmCloud::Streaming.embed
- Defined in:
- lib/dm_cloud/streaming.rb
.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>
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dm_cloud/streaming.rb', line 25 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 |