Commit c871e645 authored by Daniel Moberly's avatar Daniel Moberly
Browse files

Adding a soundmanager2 360 player theme function

parent 37082d7e
Loading
Loading
Loading
Loading
+58 −44
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ function audiofield_players() {
    'name' => 'SoundManager2 360',
    'download_link' => 'http://www.schillmania.com/projects/soundmanager2/',
    'filetypes' => array('mp3', 'wav'),
    'callback' => 'audiofield_soundmanager2',
    'callback' => 'audiofield_soundmanager2_360player',
  );

  $players['jplayer'] = array(
@@ -122,6 +122,9 @@ function _audiofield_theme() {
    'audiofield_players_premium_beat_mini' => array(
      'variables' => array('player_path' => NULL, 'audio_file' => NULL),
    ),
    'audiofield_players_soundmanager2_360player' => array(
      'variables' => array('player_path' => NULL, 'audio_file' => NULL),
    ),
  );
}

@@ -307,19 +310,31 @@ function theme_audiofield_players_premium_beat_mini($variables) {
}

/**
 * Callback function for AudioField SoundManager2 player.
 * Callback function for AudioField SoundManager2 360 player.
 */
function audiofield_soundmanager2_360player($player_path, $audio_file) {
  return theme('audiofield_players_soundmanager2_360player', array(
    'player_path' => $player_path,
    'audio_file' => file_create_url($audio_file),
  ));
}

/**
 * Theme function for AudioField Soundmanager 2 360 player.
 */
function audiofield_soundmanager2($player_path, $audio_file) {
  static $instanceIndex = 0;
  if ($audio_file == '') {
    return t('HTML5 media player for soundmanager2 (skin 360-player)');
function theme_audiofield_players_soundmanager2_360player($variables) {
  if ($variables['audio_file'] == '') {
    return array(
      '#type' => 'container',
      '#attributes' => array(),
      '#children' => t('HTML5 media player for soundmanager2 (skin 360-player)'),
    );
  }
  else {
    $instanceIndex += 1;

  $player_base_path = variable_get('audiofield_players_dir', 'sites/all/libraries/player') . "/soundmanager2";
  $ie_js = array(
    '#type' => 'markup',
      '#markup' => '<!--[if IE]><script type="text/javascript" src="' . $player_path . '/demo/360-player/script/excanvas.js"></script><![endif]-->',
    '#markup' => '<!--[if IE]><script type="text/javascript" src="' . $variables['player_path'] . '/demo/360-player/script/excanvas.js"></script><![endif]-->',
  );
  drupal_add_html_head($ie_js, 'audiofield');

@@ -330,7 +345,7 @@ function audiofield_soundmanager2($player_path, $audio_file) {
  drupal_add_js($player_base_path . '/demo/360-player/script/360player.js', array('weight' => 1));
  drupal_add_css($player_base_path . '/demo/360-player/360player.css');
  drupal_add_js('
      soundManager.url = "' . $player_path . '/swf";
    soundManager.url = "' . $variables['player_path'] . '/swf";
    soundManager.useFastPolling = true;
    soundManager.waitForWindowLoad = true;
    soundManager.preferFlash = true;
@@ -353,10 +368,9 @@ function audiofield_soundmanager2($player_path, $audio_file) {
        'ui360',
      ),
    ),
      '#children' => '<a href="' . file_create_url($audio_file) . '"></a>',
    '#children' => '<a href="' . $variables['audio_file'] . '"></a>',
  );
}
}

/**
 * Callback function for AudioField Flowplayer player.