View source
<?php
define('WIJERING4_MEDIAPLAYER', 'wijering4_mediaplayer');
define('WIJERING4_IMAGEROTATOR', 'wijering4_imagerotator');
define('WIJERING4_DOWNLOAD', 'http://www.jeroenwijering.com/?item=JW_FLV_Media_Player');
function wijering4_swftools_methods() {
$methods = array();
$media_player = array(
'name' => WIJERING4_MEDIAPLAYER,
'module' => 'wijering4',
'file' => 'file',
'version' => '7',
'shared_file' => 'flash_media_player/player.swf',
'title' => t('JW Media Player 4 - Jeroen Wijering'),
'download' => WIJERING4_DOWNLOAD,
);
$methods[SWFTOOLS_FLV_DISPLAY][WIJERING4_MEDIAPLAYER] = $media_player;
$methods[SWFTOOLS_FLV_DISPLAY_LIST][WIJERING4_MEDIAPLAYER] = $media_player;
$methods[SWFTOOLS_MP3_DISPLAY][WIJERING4_MEDIAPLAYER] = $media_player;
$methods[SWFTOOLS_MP3_DISPLAY_LIST][WIJERING4_MEDIAPLAYER] = $media_player;
$methods[SWFTOOLS_MEDIA_DISPLAY][WIJERING4_MEDIAPLAYER] = $media_player;
$methods[SWFTOOLS_MEDIA_DISPLAY_LIST][WIJERING4_MEDIAPLAYER] = $media_player;
$methods[SWFTOOLS_IMAGE_DISPLAY_LIST][WIJERING4_MEDIAPLAYER] = $media_player;
return $methods;
}
function wijering4_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/media/swf/wijering4',
'title' => t('JW Media Player 4'),
'callback' => 'drupal_get_form',
'callback arguments' => 'wijering4_admin_form',
'description' => 'Settings for ' . l('Jeroen Wijering\'s FLV Media Player 4', WIJERING4_DOWNLOAD) . '.',
);
}
return $items;
}
function wijering4_admin_form() {
drupal_set_title('JW Media Player 4');
include_once drupal_get_path('module', 'wijering4') . '/wijering4.admin.inc';
return _wijering4_admin_form();
}
function wijering4_admin_form_submit($form_id, &$form_values) {
include_once drupal_get_path('module', 'wijering4') . '/wijering4.admin.inc';
return _wijering4_admin_form_submit($form_id, $form_values);
}
function _wijering4_settings($player) {
switch ($player) {
case WIJERING4_MEDIAPLAYER:
$defaults['boolean'] = array(
'shuffle' => 'default',
'fullscreen' => 'default',
'autostart' => 'default',
'quality' => 'default',
);
$defaults['color'] = array(
'backcolor' => '',
'frontcolor' => '',
'lightcolor' => '',
'screencolor' => '',
);
$defaults['url'] = array(
'logo' => '',
'captions' => '',
'link' => '',
'streamscript' => '',
'skin' => '',
);
$defaults['integer'] = array(
'width' => '400',
'height' => '320',
'playlistsize' => '',
'bufferlength' => '',
'volume' => '',
);
$defaults['other'] = array(
'type' => 'default',
'repeat' => 'default',
'linktarget' => 'default',
'stretching' => 'default',
'playlist' => 'default',
'controlbar' => 'default',
'displayclick' => 'default',
);
$saved_settings = variable_get('swftools_' . WIJERING4_MEDIAPLAYER, array());
break;
}
foreach ($defaults as $category => $vars) {
foreach ($vars as $key => $setting) {
if (isset($saved_settings[$key])) {
$defaults[$category][$key] = $saved_settings[$key];
}
}
}
return $defaults;
}
function wijering4_swftools_flashvars($action, &$methods, &$vars) {
$saved_settings = _wijering4_flashvars($methods->player['name']);
$saved = array();
foreach ($saved_settings as $category => $settings) {
$saved = array_merge($saved, $settings);
}
$flashvars = array_merge($saved, $vars->flashvars);
if (isset($flashvars['image']) && !valid_url($flashvars['image'], TRUE)) {
$flashvars['image'] = swftools_get_media_url(swftools_get_media_path() . $flashvars['image']);
}
if ($vars->params['width']) {
$flashvars['width'] = $vars->params['width'];
}
if ($vars->params['height']) {
$flashvars['height'] = $vars->params['height'];
}
return $flashvars;
}
function _wijering4_flashvars($this_player) {
static $flashvars = array();
if (!count($flashvars)) {
foreach (array(
WIJERING4_MEDIAPLAYER,
) as $player) {
$defaults = _wijering4_settings($player);
foreach ($defaults as $category => $vars) {
foreach ($vars as $key => $setting) {
if ($setting == '' || $setting == 'default') {
unset($defaults[$category][$key]);
}
else {
switch ($category) {
case 'color':
$defaults['color'][$key] = str_replace('#', '0x', $defaults['color'][$key]);
break;
case 'boolean':
$defaults['boolean'][$key] = _swftools_tf($defaults['boolean'][$key]);
break;
}
}
}
}
if ($defaults['integer']['displaywidth']) {
unset($defaults['integer']['displayheight']);
}
else {
unset($defaults['integer']['displaywidth']);
}
$flashvars[$player] = $defaults;
}
}
return $flashvars[$this_player];
}
function _wijering4_options() {
$options['type'] = array(
'default' => 'default',
'sound' => 'sound',
'image' => 'image',
'video' => 'video',
'youtube' => 'youtube',
'camera' => 'camera',
'http' => 'http',
'rtmp' => 'rtmp',
);
$options['overstretch'] = array(
'default' => 'default',
'uniform' => 'uniform',
'fill' => 'fill',
'exactfit' => 'exactfit',
'none' => 'none',
);
$options['repeat'] = array(
'default' => 'default',
'none' => 'none',
'list' => 'list',
'always' => 'always',
);
$options['linktarget'] = array(
'default' => 'default',
'_self' => '_self',
'_blank' => '_blank',
'none' => 'none',
);
$options['playlist'] = array(
'default' => 'default',
'bottom' => 'bottom',
'over' => 'over',
'right' => 'right',
'none' => 'none',
);
$options['controlbar'] = array(
'default' => 'default',
'bottom' => 'bottom',
'over' => 'over',
'none' => 'none',
);
$options['displayclick'] = array(
'default' => 'default',
'play' => 'play',
'link' => 'link',
'fullscreen' => 'fullscreen',
'none' => 'none',
'mute' => 'mute',
'next' => 'next',
);
$options['bool'] = array(
'default' => 'default',
'true' => 'true',
'false' => 'false',
);
return $options;
}
function swftools_wijering4_mediaplayer_playlist($xml_data, &$method, &$vars) {
$xml = '<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>' . $xml_data['header']['title'] . '</title>
<info></info>
<annotation></annotation>
<trackList>
';
foreach ($xml_data['playlist'] as $track => $details) {
if (!isset($details['background']) && strtolower(substr($details['fileurl'], -3, 3)) == 'mp3') {
if (isset($vars->flashvars['image'])) {
$details['background'] = swftools_get_media_url(swftools_get_media_path() . $vars->flashvars['image']);
}
else {
$details['background'] = SWFTOOLS_DEFAULT_BG;
}
}
$xml .= "<track>\n";
$xml .= "<title>" . $details['title'] . "</title>\n";
$xml .= "<creator></creator>\n";
$xml .= "<location>" . $details['fileurl'] . "</location>\n";
$xml .= "<image>" . $details['background'] . "</image>\n";
$xml .= "<info>" . $details['fileurl'] . "</info>\n";
$xml .= "</track>\n";
}
$xml .= '</trackList>
</playlist>';
return $xml;
}
function wijering4_swftools_variable_mapping() {
return array(
WIJERING4_MEDIAPLAYER => array(
'shuffle' => 'flashvars',
'fullscreen' => 'flashvars',
'autostart' => 'flashvars',
'quality' => 'flashvars',
'backcolor' => 'flashvars',
'frontcolor' => 'flashvars',
'lightcolor' => 'flashvars',
'screencolor' => 'flashvars',
'logo' => 'flashvars',
'captions' => 'flashvars',
'link' => 'flashvars',
'streamscript' => 'flashvars',
'skin' => 'flashvars',
'playlistsize' => 'flashvars',
'bufferlength' => 'flashvars',
'volume' => 'flashvars',
'type' => 'flashvars',
'repeat' => 'flashvars',
'linktarget' => 'flashvars',
'stretching' => 'flashvars',
'playlist' => 'flashvars',
'controlbar' => 'flashvars',
'displayclick' => 'flashvars',
),
);
}