function osmplayer_get_player in MediaFront 7.2
Same name and namespace in other branches
- 6.2 players/osmplayer/osmplayer.module \osmplayer_get_player()
- 6 players/osmplayer/osmplayer.module \osmplayer_get_player()
- 7 players/osmplayer/osmplayer.module \osmplayer_get_player()
Implements hook_get_player()
File
- players/
osmplayer/ osmplayer.module, line 9
Code
function osmplayer_get_player($params) {
global $base_url;
$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 |= !empty($params['admin']);
// For reverse compatability...
if (!empty($params['playlistObj'])) {
$params['playlist'] = $params['playlistObj'];
}
// If they provide the playlist object, encode it as JSON.
if (!empty($params['playlist'])) {
switch (gettype($params['playlist'])) {
case 'string':
if (!preg_match('/^http(s)?:\\/\\//', $params['playlist'])) {
$params['playlist'] = '/mediafront_getplaylist/' . $params['playlist'];
}
$showPlayer = TRUE;
break;
case 'object':
$params['playlist'] = (array) $params['playlist'];
case 'array':
$showPlayer |= !empty($params['playlist']['total_rows']);
break;
default:
break;
}
}
// If they provide the node object, encode it as JSON.
if (!empty($params['nodeObj'])) {
$showPlayer |= isset($params['nodeObj']['mediafiles']) && count($params['nodeObj']['mediafiles']) > 0;
$params['node'] = $params['nodeObj'];
}
else {
$showPlayer |= isset($params['node']['mediafiles']) && count($params['node']['mediafiles']) > 0;
}
// Add the pre-reel and post-reel
if (!empty($params['prereel']) && empty($params['node']['mediafiles']['media']['prereel'])) {
$params['node']['mediafiles']['media']['prereel'] = new MediaFile($params['prereel']);
}
if (!empty($params['postreel']) && empty($params['node']['mediafiles']['media']['postreel'])) {
$params['node']['mediafiles']['media']['postreel'] = new MediaFile($params['postreel']);
}
// Get and encode the player parameters.
if (!empty($params['logo'])) {
$params['logo'] = $base_url . '/' . ltrim($params['logo'], '/');
}
$params['swfplayer'] = $base_url . '/' . ltrim($params['swfplayer'], '/');
// Add the core media player files.
osmplayer_add_core_files($params);
$player_params = module_invoke_all('osmplayer_params', $params);
$params = array_merge($params, $player_params);
$player_params['node'] =& $params['node'];
// Allow other modules to alter the params.
drupal_alter('osmplayer_params', $params, $player_params);
// Get the id.
$id = $params['id'];
$output = '';
// Iterate through each parameter and filter it for output.
foreach ($params as $param => &$value) {
if (gettype($value) == 'string' && $param != 'node') {
$value = check_plain($value);
}
}
// If we wish to show the media player.
if ($showPlayer) {
$output = theme('osmplayer_' . $params['template'], array(
'params' => $params,
));
// Add the playlist connections.
$output .= osmplayer_add_connection($params, 'playlist');
// Add the controller connectiions.
$output .= osmplayer_add_connection($params, 'controller');
// Add the settings.
$output .= osmplayer_get_settings_output('mediafront', array(
$id => $player_params,
));
}
// Show the player.
return $output;
}