You are here

function osmplayer_get_player in MediaFront 6

Same name and namespace in other branches
  1. 6.2 players/osmplayer/osmplayer.module \osmplayer_get_player()
  2. 7.2 players/osmplayer/osmplayer.module \osmplayer_get_player()
  3. 7 players/osmplayer/osmplayer.module \osmplayer_get_player()

Implementation of hook_get_player()

File

players/osmplayer/osmplayer.module, line 9

Code

function osmplayer_get_player($params) {
  $template = isset($params['template']) && $params['template'] ? $params['template'] : "default";
  $showPlayer = isset($params['showWhenEmpty']) ? $params['showWhenEmpty'] : TRUE;

  // Always show the player when viewing through the admin interface.
  $showPlayer |= $params['admin'];

  // If they provide the playlist object, encode it as JSON.
  if (isset($params['playlistObj']) && $params['playlistObj']) {
    $showPlayer |= $params['playlistObj']['total_rows'] > 0;
    $params['playlist'] = mediafront_json_encode($params['playlistObj']);
  }
  else {
    $showPlayer |= isset($params['playlist']) && $params['playlist'];
  }

  // If they provide the node object, encode it as JSON.
  if (isset($params['nodeObj']) && $params['nodeObj']) {
    $showPlayer |= isset($params['nodeObj']['mediafiles']) && count($params['nodeObj']['mediafiles']) > 0;
    $params['node'] = mediafront_json_encode($params['nodeObj']);
  }
  else {
    $showPlayer |= isset($params['node']) && $params['node'];
  }

  // Iterate through each parameter and filter it for output.
  foreach ($params as $param => &$value) {
    if (gettype($value) == 'string') {
      $value = check_plain($value);
    }
  }

  // Show the player.
  return $showPlayer ? theme('osmplayer_' . $template, $params) : '';
}