You are here

function mediafront_get_player in MediaFront 6.2

Same name and namespace in other branches
  1. 6 mediafront.module \mediafront_get_player()
  2. 7.2 mediafront.module \mediafront_get_player()
  3. 7 mediafront.module \mediafront_get_player()

Returns a media player.

Parameters

- This can either be an associative array with the settings,: or can be the preset string followed by another argument that is the associative array with the settings you wish to override for that preset.

Example: To show the player with settings...

$params['playlist'] = 'videos'; print mediafront_get_player( $params );

Example: To show the player with the 'mypreset' preset.

print mediafront_get_player( 'mypreset' );

Example: To show the player with the 'mypreset' with the settings overrides.

$params['playlist'] = 'videos'; print mediafront_get_player( 'mypreset', $params );

5 calls to mediafront_get_player()
mediafront_block_content in ./mediafront.module
Content for the media player block.
mediafront_preset_form in includes/mediafront.preset.inc
theme_mediafront_field in ./mediafront.module
Implement the theme for a view field media player.
theme_mediafront_player in ./mediafront.module
Implement the theme for a node media player.
theme_mediafront_player_view in ./mediafront.module
Implement the theme for a views media player.

File

./mediafront.module, line 927

Code

function mediafront_get_player() {
  $args = func_get_args();
  $params = $args[0];

  // If they pass in a string, then this is a preset.
  // get the preset values.
  if (gettype($params) == 'string') {
    $preset = mediafront_get_preset($params);
    $params = isset($args[1]) ? $preset['settings'] ? array_merge($preset['settings'], $args[1]) : $args[1] : $preset['settings'];
    $params['preset'] = $preset['name'];
    $params['player'] = $preset['player'];
    $params['protocol'] = 'json';
    $params['connect'] = isset($params['connect']) && $params['connect'] ? $params['connect'] : $preset['connect'];
    $params['id'] = isset($params['id']) && $params['id'] ? $params['id'] : 'mediafront_' . $preset['name'];
  }
  if ($params && is_array($params)) {
    $player = $params && $params['player'] ? $params['player'] : 'osmplayer';
    $getPlayer = $player . '_get_player';
    return function_exists($getPlayer) ? $getPlayer($params) : t('Player not available');
  }
  else {
    return t('Player not available');
  }
}