Module: KalturaFu::ViewHelpers
- Defined in:
- lib/kaltura_fu/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_fu(*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_fu(*args) ⇒ Object
Convienence to include SWFObject and the required Kaltura upload embed javascripts.
19 20 21 22 23 |
# File 'lib/kaltura_fu/view_helpers.rb', line 19 def include_kaltura_fu(*args) content = javascript_include_tag('kaltura_upload') content << "\n#{javascript_include_tag('http://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.
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_fu/view_helpers.rb', line 75 def (entry_id,={}) player_conf_parameter = "/ui_conf_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 KalturaFu.config[:player_conf_id].nil? player_conf_parameter += "#{KalturaFu.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\" }; 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(\"#{KalturaFu.config[:service_url]}/kwidget/wid/_#{KalturaFu.config[:partner_id]}" + player_conf_parameter + "\",\"#{[:div_id]}\",\"#{width}\",\"#{height}\",\"10.0.0\",\"http://ttv.mit.edu/swfs/expressinstall.swf\",flashVars,params,attributes); </script>" end |
#kaltura_seek_link(content, seek_time, options = {}) ⇒ Object
Creates a link_to tag that seeks to a certain time on a KDPv3 player.
172 173 174 175 176 177 178 |
# File 'lib/kaltura_fu/view_helpers.rb', line 172 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.
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 61 |
# File 'lib/kaltura_fu/view_helpers.rb', line 34 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 KalturaFu.config[:thumb_width] && KalturaFu.config[:thumb_height] size_parameters = "/width/#{KalturaFu.config[:thumb_width]}/height/" + "#{KalturaFu.config[:thumb_height]}" end end unless [:second].nil? seconds_parameter = "/vid_sec/#{[:second]}" else seconds_parameter = "/vid_sec/5" end image_tag("#{KalturaFu.config[:service_url]}/p/#{KalturaFu.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 |
# File 'lib/kaltura_fu/view_helpers.rb', line 132 def (={}) [: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: \"#{KalturaFu.config[:partner_id]}\", subPId: \"#{KalturaFu.config[:subpartner_id]}\", entryId: \"-1\", ks: \"#{KalturaFu.session_key}\", uiConfId: '1103', jsDelegate: \"delegate\", maxFileSize: \"999999999\", maxTotalSize: \"999999999\" }; swfobject.embedSWF(\"#{KalturaFu.config[:service_url]}/kupload/ui_conf_id/1103\", \"uploader\", \"160\", \"26\", \"9.0.0\", \"expressInstall.swf\", flashVars, params,attributes); </script>" end |