Module: JWPlayer::Rails::Helper

Defined in:
lib/jwplayer/rails/helper.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  id: 'jwplayer',
  flashplayer: '/assets/player.swf',
  width: '400',
  height: '300'
}

Instance Method Summary collapse

Instance Method Details

#jwplayer(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/jwplayer/rails/helper.rb', line 15

def jwplayer(options = {})
  options = DEFAULT_OPTIONS.merge(options)

  result = %Q{<div id='#{options[:id]}'>This div will be replaced by the JW Player.</div>
              <script type='text/javascript'>
                jwplayer('#{options[:id]}').setup(#{options.except(:id).to_json});
              </script>}

  result.respond_to?(:html_safe) ? result.html_safe : result
end

#jwplayer_assetsObject

Includes JWPlayer javascript library



11
12
13
# File 'lib/jwplayer/rails/helper.rb', line 11

def jwplayer_assets
  javascript_include_tag "jwplayer"
end