You are here

function theme_filefieldmp3player_formatter_mp3player in MP3 Player 6

Same name and namespace in other branches
  1. 6.2 filefieldmp3player/filefieldmp3player.module \theme_filefieldmp3player_formatter_mp3player()

Formatter theme function for file fields presented as a Flash MP3 Player.

1 string reference to 'theme_filefieldmp3player_formatter_mp3player'
filefieldmp3player_theme in filefieldmp3player/filefieldmp3player.module
Implementation of hook_theme().

File

filefieldmp3player/filefieldmp3player.module, line 49

Code

function theme_filefieldmp3player_formatter_mp3player($element) {
  $item = $element['#item'];
  if ($item['list'] == "0") {

    // Isn't listed so bail now
    return;
  }
  if (variable_get('mp3player_description', 'description') == 'id3' && module_exists(getid3) && getid3_load() == TRUE) {
    $id3 = getid3_analyze($item['filepath']);
    $title = $info['tags']['id3v2']['title'][0];
    $artist = $info['tags']['id3v2']['artist'][0];
    $album = $info['tags']['id3v2']['album'][0];
    $year = $info['tags']['id3v2']['year'][0];
    $track = $info['tags']['id3v2']['track'][0];
    $genre = $info['tags']['id3v2']['genre'][0];
    $description = theme('filefieldmp3player_description', $id3);
  }
  else {
    if (isset($item['data']['description']) && is_array($item['data'])) {

      //Data straight from node isn't serialized
      $description = $item['data']['description'];
    }
    else {
      if (isset($item['data']['description']) && is_array(unserialize($item['data']))) {

        //Data from a View is on the other hand
        $bits = unserialize($item['data']);
        $description = $bits['description'];
      }
    }
  }
  $parts = explode('_', $element['#formatter']);
  unset($parts[0]);
  $player = implode('_', $parts);
  if (!empty($item['filepath'])) {
    if ($item['filemime'] == 'audio/mpeg' || $item['filemime'] == 'audio/x-mpeg' || $item['filemime'] == 'audio/mp3' || $item['filemime'] == 'audio/x-mp3' || $item['filemime'] == 'audio/mpeg3' || $item['filemime'] == 'audio/x-mpeg3' || $item['filemime'] == 'audio/mpg' || $item['filemime'] == 'audio/x-mpg' || $item['filemime'] == 'audio/mpegaudi') {

      //MP3 files get special treatment.
      return theme('mp3player', $player, file_create_url($item['filepath']), NULL, NULL, $description);
    }
    else {

      // Fall back to filefield's default behavior.
      return theme('filefield_formatter_default', $element);
    }
  }
}