Module: Mp3Player::ViewHelper

Defined in:
lib/mp3_player/view_helper.rb

Overview

This module contains the view helper mp3_player and google_mp3_player

Constant Summary collapse

@@player_count =

This counter is used to generated unique IDs

0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_player_countObject



32
33
34
# File 'lib/mp3_player/view_helper.rb', line 32

def self.reset_player_count
  @@player_count = 0
end

Instance Method Details

#google_mp3_player(path) ⇒ Object



22
23
24
25
26
# File 'lib/mp3_player/view_helper.rb', line 22

def google_mp3_player path
  %Q[
    <embed type="application/x-shockwave-flash" wmode="transparent" src="http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=#{path}" height="27" width="320"></embed>
  ].html_safe
end

#increment_player_countObject



28
29
30
# File 'lib/mp3_player/view_helper.rb', line 28

def increment_player_count
  @@player_count += 1
end

#mp3_player(path, options = {}) ⇒ Object

This is the helper method you’ll call in the view. <%= mp3_player @song.mp3.url %> See the options at wpaudioplayer.com/standalone for more info on customising the player to match your site



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mp3_player/view_helper.rb', line 9

def mp3_player path, options = {}
  increment_player_count

  options.merge!({soundFile: path})

  %Q[
    <p id="audioplayer_#{@@player_count}">Alternative content</p>
      <script type="text/javascript">
        AudioPlayer.embed("audioplayer_#{@@player_count}", #{options.to_json});
      </script>
  ].html_safe
end