Method: KalturaFu::ViewHelpers#kaltura_player_embed

Defined in:
lib/kaltura_fu/view_helpers.rb

#kaltura_player_embed(entry_id, options = {}) ⇒ String

Returns the code needed to embed a KDPv3 player.

Parameters:

  • entry_id (String)

    Kaltura entry_id

  • options (Hash) (defaults to: {})

    the embed code options.

Options Hash (options):

  • :div_id (String) — default: 'kplayer'

    The div element that the flash object will be inserted into.

  • :size (Array) — default: []

    The [width,wight] of the player.

  • :use_url (Boolean) — default: false

    flag to determine whether entry_id is an entry or a URL of a flash file.

  • :player_conf_id (String) — default: KalturaFu.config(:player_conf_id)

    A UI Conf ID to override the player with.

Returns:

  • (String)

    returns a string representation of the html/javascript necessary to play a Kaltura entry.



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
125
# File 'lib/kaltura_fu/view_helpers.rb', line 75

def kaltura_player_embed(entry_id,options={})
  player_conf_parameter = "/ui_conf_id/"
  options[:div_id] ||= "kplayer"
  options[:size] ||= []
  options[:use_url] ||= false
  width = PLAYER_WIDTH
  height = PLAYER_HEIGHT
  source_type = "entryId"

  unless options[:size].empty?
   width = options[:size].first
   height = options[:size].last
  end
    
  if options[:use_url] == true
    source_type = "url"
  end

  unless options[:player_conf_id].nil?
    player_conf_parameter += "#{options[: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=\"#{options[: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: \"#{options[:div_id]}\",
      name: \"#{options[:div_id]}\"
  	};

  	swfobject.embedSWF(\"#{KalturaFu.config.service_url}/kwidget/wid/_#{KalturaFu.config.partner_id}" + player_conf_parameter + "\",\"#{options[:div_id]}\",\"#{width}\",\"#{height}\",\"10.0.0\",\"http://ttv.mit.edu/swfs/expressinstall.swf\",flashVars,params,attributes);
  </script>"
end