You are here

function theme_mp3player in MP3 Player 6.2

Same name and namespace in other branches
  1. 6 mp3player.module \theme_mp3player()
  2. 7.2 mp3player.module \theme_mp3player()

Setup theme function for the MP3 Player.

1 theme call to theme_mp3player()
theme_filefieldmp3player_formatter_mp3player in filefieldmp3player/filefieldmp3player.module
Formatter theme function for file fields presented as a Flash MP3 Player.

File

./mp3player.module, line 632
mp3player main module file.

Code

function theme_mp3player($player = 'Default', $file = NULL, $title = NULL, $artist = NULL, $description = NULL) {

  // Add JS
  drupal_add_js(libraries_get_path('audio-player') . '/audio-player.js', 'module', 'footer');
  drupal_add_js(drupal_get_path('module', 'mp3player') . '/mp3player.js', 'module', 'footer');
  $extras = NULL;
  $js_audio_settings = mp3player_player_settings();
  drupal_add_js($js_audio_settings, 'inline', 'footer');

  // Setup player
  static $mp3_player_id;
  $mp3_player_id++;
  if ($title != NULL) {
    $title = filter_xss($title);
    $extras .= ',titles:"' . addslashes($title) . '"';
  }
  if ($artist != NULL) {
    $artist = filter_xss($artist);
    $extras .= ',artists:"' . addslashes($artist) . '"';
  }
  if ($description != NULL) {
    $description = filter_xss($description);
    $description = '<p class="mp3player_description">' . $description . '</p>';
  }
  if (module_exists('simplecdn')) {
    $file = simplecdn_rewrite_url($file, 'mp3player');
  }
  if (variable_get('mp3player_encode', 'no') == 'yes') {
    $audio_url = mp3player_encodeSource($file);
  }
  else {
    $audio_url = $file;
  }
  $audio_url = url($audio_url);
  $extras = str_replace('"', "", $extras);
  $extras = str_replace(":", "=", $extras);
  $extras = str_replace(" ", "", $extras);
  $extras = str_replace(",", "&", $extras);
  $out = array();
  $out[] = '<p id="mp3player_' . $mp3_player_id . '" class="mp3player" data="soundFile=' . $audio_url . $extras . '">';
  $out[] = t("You may need: <a href='http://get.adobe.com/flashplayer/'>Adobe Flash Player</a>.");
  $out[] = '</p>';
  $out[] = $description;
  return implode('', $out);
}