Module: KalturaBox::ViewHelpers
- Defined in:
- lib/kaltura_box/view_helpers.rb
Overview
The ViewHelpers module provides extensions to Rails ActionView class that allow interactions with Kaltura on rails view layer.
Constant Summary collapse
- DEFAULT_KPLAYER =
default UI Conf ID of the kdp player
'1339442'
- PLAYER_WIDTH =
default embedded KDP width
'400'
- PLAYER_HEIGHT =
default embedded KDP height
'330'
Instance Method Summary collapse
-
#include_kaltura_box(*args) ⇒ Object
Convienence to include SWFObject and the required Kaltura upload embed javascripts.
-
#kaltura_player_embed(entry_id, options = {}) ⇒ String
Returns the code needed to embed a KDPv3 player.
-
#kaltura_seek_link(content, seek_time, options = {}) ⇒ Object
Creates a link_to tag that seeks to a certain time on a KDPv3 player.
-
#kaltura_thumbnail(entry_id, options = {}) ⇒ String
Returns the thumbnail of the provided Kaltura Entry.
-
#kaltura_upload_embed(options = {}) ⇒ Object
Returns the html/javascript necessary for a KSU widget.
Instance Method Details
#include_kaltura_box(*args) ⇒ Object
Convienence to include SWFObject and the required Kaltura upload embed javascripts.
19 20 21 22 |
# File 'lib/kaltura_box/view_helpers.rb', line 19 def include_kaltura_box(*args) content = javascript_include_tag('kaltura_upload') content << javascript_include_tag('//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js') end |
#kaltura_player_embed(entry_id, options = {}) ⇒ String
Returns the code needed to embed a KDPv3 player.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/kaltura_box/view_helpers.rb', line 74 def (entry_id,={}) player_conf_parameter = "/uiconf_id/" [:div_id] ||= "kplayer" [:size] ||= [] [:use_url] ||= false width = PLAYER_WIDTH height = PLAYER_HEIGHT source_type = "entryId" unless [:size].empty? width = [:size].first height = [:size].last end if [:use_url] == true source_type = "url" end unless [:player_conf_id].nil? player_conf_parameter += "#{[:player_conf_id]}" else unless KalturaBox.config.player_conf_id.nil? player_conf_parameter += "#{KalturaBox.config.player_conf_id}" else player_conf_parameter += "#{DEFAULT_KPLAYER}" end end "<div id=\"#{[:div_id]}\"></div> <script type=\"text/javascript\"> var params= { allowscriptaccess: \"always\", allownetworking: \"all\", allowfullscreen: \"true\", wmode: \"opaque\", bgcolor: \"#000000\" }; var flashVars = {}; flashVars.sourceType = \"#{source_type}\"; flashVars.entryId = \"#{entry_id}\"; flashVars.emptyF = \"onKdpEmpty\"; flashVars.readyF = \"onKdpReady\"; var attributes = { id: \"#{[:div_id]}\", name: \"#{[:div_id]}\" }; swfobject.embedSWF(\"#{KalturaBox.config.service_url}/kwidget/wid/_#{KalturaBox.config.partner_id}" + player_conf_parameter + "\",\"#{[:div_id]}\",\"#{width}\",\"#{height}\",\"10.0.0\",\"http://ttv.mit.edu/swfs/expressinstall.swf\",flashVars,params,attributes); </script>".html_safe end |
#kaltura_seek_link(content, seek_time, options = {}) ⇒ Object
Creates a link_to tag that seeks to a certain time on a KDPv3 player.
173 174 175 176 177 178 179 |
# File 'lib/kaltura_box/view_helpers.rb', line 173 def kaltura_seek_link(content,seek_time,={}) [:div_id] ||= "kplayer" [:onclick] = "$(#{[:div_id]}).get(0).sendNotification('doSeek',#{seek_time});window.scrollTo(0,0);return false;" .delete(:div_id) link_to(content,"#", ) end |
#kaltura_thumbnail(entry_id, options = {}) ⇒ String
Returns the thumbnail of the provided Kaltura Entry.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kaltura_box/view_helpers.rb', line 33 def kaltura_thumbnail(entry_id,={}) [:size] ||= [] size_parameters = "" seconds_parameter = "" unless [:size].empty? size_parameters = "/width/#{[:size].first}/height/" + "#{[:size].last}" else # if the thumbnail width and height are defined in the config, # use it, assuming it wasn't locally overriden if KalturaBox.config.thumb_width && KalturaBox.config.thumb_height size_parameters = "/width/#{KalturaBox.config.thumb_width}/height/" + "#{KalturaBox.config.thumb_height}" end end unless [:second].nil? seconds_parameter = "/vid_sec/#{[:second]}" else seconds_parameter = "/vid_sec/5" end image_tag("#{KalturaBox.config.service_url}/p/#{KalturaBox.config.partner_id}" + "/thumbnail/entry_id/#{entry_id}" + seconds_parameter + size_parameters) end |
#kaltura_upload_embed(options = {}) ⇒ Object
Returns the html/javascript necessary for a KSU widget.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/kaltura_box/view_helpers.rb', line 132 def (={}) client = KalturaBox::Client.update_session [:div_id] ||="uploader" "<div id=\"#{[:div_id]}\"></div> <script type=\"text/javascript\"> var params = { allowScriptAccess: \"always\", allowNetworking: \"all\", wmode: \"transparent\" }; var attributes = { id: \"uploader\", name: \"KUpload\" }; var flashVars = { uid: \"ANONYMOUS\", partnerId: \"#{KalturaBox.config.partner_id}\", subPId: \"#{KalturaBox.config.partner_id}00\", entryId: \"-1\", ks: \"#{client.session_key}\", uiConfId: '4211621', jsDelegate: \"delegate\", maxFileSize: \"999999999\", maxTotalSize: \"999999999\" }; swfobject.embedSWF(\"#{KalturaBox.config.service_url}/kupload/ui_conf_id/4211621\", \"uploader\", \"160\", \"26\", \"9.0.0\", \"expressInstall.swf\", flashVars, params,attributes); </script>".html_safe end |