You are here

function theme_asset_bonus_mp3player in Asset 5

Same name and namespace in other branches
  1. 5.2 contrib/asset_bonus/asset_bonus.module \theme_asset_bonus_mp3player()
  2. 6 asset_bonus/asset_bonus.module \theme_asset_bonus_mp3player()
  3. 6 contrib/asset_bonus/asset_bonus.module \theme_asset_bonus_mp3player()
1 theme call to theme_asset_bonus_mp3player()
asset_bonus_mp3player_preview in asset_bonus/asset_bonus.module

File

asset_bonus/asset_bonus.module, line 324

Code

function theme_asset_bonus_mp3player($asset, $options = array()) {

  // We're not using drupal_add_js(drupal_get_path('module','asset_bonus') .'/swfobject/swfobject.js') because of caching issues
  // We're not using drupal_add_js(drupal_get_path('module','asset_bonus') .'/audioplayer/audio-player.js') because of caching issues
  $swfobject = base_path() . drupal_get_path('module', 'asset_bonus') . '/swfobject/swfobject.js';
  $audobject = base_path() . drupal_get_path('module', 'asset_bonus') . '/audioplayer/audio-player.js';
  $swffile = base_path() . drupal_get_path('module', 'asset_bonus') . '/audioplayer/player.swf';
  $colors = asset_bonus_mp3player_colors();
  foreach ($colors as $key => $color_data) {
    $color = variable_get('asset_bonus_mp3player_' . $key, $color_data['default']);
    if ($color) {
      $color = str_replace('#', '0x', $color);
      $colorvars .= "oSwf.addVariable('{$key}','{$color}');";
    }
  }
  $default = array(
    'width' => 290,
    'height' => 24,
  );
  if (is_array($options)) {
    $options += $default;
  }
  else {
    $options = $default;
  }
  $output = <<<OUT
  <script type="text/javascript" src="{<span class="php-variable">$swfobject</span>}"></script>
  <script type="text/javascript" src="{<span class="php-variable">$audobject</span>}"></script>
  <div id="mp3player-{<span class="php-variable">$asset</span>-&gt;<span class="php-function-or-constant property member-of-variable">aid</span>}" class="asset-swfobject">Audio placeholder</div>
  <script type="text/javascript" defer="defer">
    var oSwf = new SWFObject("{<span class="php-variable">$swffile</span>}","mp3player-object-{<span class="php-variable">$asset</span>-&gt;<span class="php-function-or-constant property member-of-variable">aid</span>}","{<span class="php-variable">$options</span>[<span class="php-string">'width'</span>]}","{<span class="php-variable">$options</span>[<span class="php-string">'height'</span>]}","7","#FFFFFF");
    oSwf.addVariable('playerID','{<span class="php-variable">$asset</span>-&gt;<span class="php-function-or-constant property member-of-variable">aid</span>}');
    oSwf.addVariable('soundFile','{<span class="php-variable">$asset</span>-&gt;<span class="php-function-or-constant property member-of-variable">url</span>}');
    {<span class="php-variable">$colorvars</span>}
    oSwf.addParam('wmode','transparent');
    oSwf.addParam('menu','false');
    oSwf.write("mp3player-{<span class="php-variable">$asset</span>-&gt;<span class="php-function-or-constant property member-of-variable">aid</span>}");
    oSwf = null;
  </script>
OUT;
  return $output;
}