Module: Mp3Player::LayoutHelper

Defined in:
lib/mp3_player/layout_helper.rb

Instance Method Summary collapse

Instance Method Details

#mp3_player_headers(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mp3_player/layout_helper.rb', line 3

def mp3_player_headers options = {}
  ViewHelper.reset_player_count

  # Don't reload configuration options in production env
  Configuration.load_options if !Rails.env.production?

  options.reverse_merge! Mp3Player.default_options if Mp3Player.default_options
  options.reverse_merge!({ width: 290 })

  audio_player_path = if options[:with_swfobject] == false
                        'audio-player-noswfobject.js'
                      else
                        'audio-player.js'
                      end

  javascript_include_tag(audio_player_path) +
      %Q[
      <script type="text/javascript">
        AudioPlayer.setup("#{asset_path('player.swf')}", #{options.to_json} );
      </script>].html_safe
end