This is simply using the drupal theme system. Stick this in your template.php file.
<?php
function phptemplate_audio_1pixelout_node_player($node, $options = array(), $size = 'default') {
switch ($size) {
case 'small':
$width = 200;
$height = 17;
break;
case 'default':
$width = 290;
$height = 24;
}
// make sure it's compatible with the flash player
if (!audio_is_flash_playable($node)) {
return NULL;
}
$options['soundFile'] = check_url($node->url_play);
$url = base_path() . drupal_get_path('module', 'audio') .'/players/1pixelout.swf';
$flashvars = audio_query_string_encode($options);
$output = <<<EOT
<object type="application/x-shockwave-flash" data="$url" width="$width" height="$height" >
<param name="movie" value="$url" />
<param name="wmode" value="transparent" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="FlashVars" value="$flashvars" />
<embed src="$url" flashvars="$flashvars" width="$width" height="$height" />
</object>
EOT;
return $output;
}
?>This overrides the theming of the player and gives us a size option. So, anytime we normally call the player it will be unchanged. But, we can call it with something like:
<?php
print theme('audio_1pixelout_node_player', $node, 'small');
?>This will give us the small player like you see on the G&G site. This help?
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
This makes sense, but how do I put my themed colors for the player in here? When I used this code I got an error telling me that I cannot redeclare the object. I had put some php in the template for theming the player, is that able to be put in this code?
Each function needs to have a unique name. So, if you want to do the colors things it gets a little complicated. try this..
<?php
function phptemplate_audio_1pixelout_node_player($node, $options = array(), $size = 'default') {
//This section is your options
$myoptions['leftbg'] = '0x000000';
$myoptions['rightbg'] = '0x000000';
$myoptions['lefticon'] = '0xFFFFFF';
$myoptions['righticon'] = '0xFFFFFF';
//end your options
$options = array_merge($myoptions, $options);
switch ($size) {
case 'small':
$width = 200;
$height = 17;
break;
case 'default':
$width = 290;
$height = 24;
}
// make sure it's compatible with the flash player
if (!audio_is_flash_playable($node)) {
return NULL;
}
$options['soundFile'] = check_url($node->url_play);
$url = base_path() . drupal_get_path('module', 'audio') .'/players/1pixelout.swf';
$flashvars = audio_query_string_encode($options);
$output = <<<EOT
<object type="application/x-shockwave-flash" data="$url" width="$width" height="$height" >
<param name="movie" value="$url" />
<param name="wmode" value="transparent" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="FlashVars" value="$flashvars" />
<embed src="$url" flashvars="$flashvars" width="$width" height="$height" />
</object>
EOT;
return $output;
}
?>The way this works will cause any options you pass to the player when you call the theme function to override the ones in this function. Check out http://mattfarina.com/2007/04/24/theming-1pixelout... for more theming details...
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
Thanks a ton, that really helps.
Hmm...it's not working...
I tried adding the $myoptions function in the other places where $options is listed by writing $myoptions, $options like you had done. It didn't work. It gives me this error:
Fatal error: Call to undefined function: audio_query_string_encode() in www/livingword/sites/all/themes/vine/template.php on line 52
It gave me the same error when I entered your code as just as you had done it as well. Line 52 being:
$flashvars = audio_query_string_encode($options);
I tried changing it to ($myoptions, $options), but it still gave me the same error message.
What I did with $myoptions, $options was to have some settings in the function ($myoptions) and some settings coming into the function as an argument ($options) and then to merge them into the variable array $options. So, there is just one set of settings that get passed ($options). I merge the two arrays together. This just gives us some more freedom with the function.
Do you have the audio module enabled? The error is coming from the function audio_query_string_encode(). If the audio module isn't enabled that would mean that function is not available.
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
Yep, the audio module is enabled and I have it being used in several places on the site.
I'm a bit lost. If the audio module is enabled that function should be available. Can you provide the exact code you are using. There must be some issue that we're missing. That function is part of the core audio module.
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
I plugged in exactly what you wrote above into my template.php file and just added the extra color options:
www.iamanoffering.com/blog<?php
function vine_regions() {
return array(
'sidebar_left' => t('left sidebar'),
'sidebar_right' => t('right sidebar'),
'content' => t('content'),
'header' => t('header'),
'footer' => t('footer'),
);
}
?>
<?php
function phptemplate_audio_1pixelout_node_player($node, $options = array(), $size = 'default') {
//This section is your options
$myoptions['leftbg'] = '0x009A66';
$myoptions['rightbg'] = '0x009A66';
$myoptions['rightbghover'] = '0x99C564';
$myoptions['lefticon'] = '0xFFFFFF';
$myoptions['righticon'] = '0xFFFFFF';
$myoptions['righticonhover'] = '0xFFFFFF';
$myoptions['bg'] = '0xFFFFFF';
//end your options
$options = array_merge($myoptions, $options);
switch ($size) {
case 'small':
$width = 200;
$height = 17;
break;
case 'default':
$width = 290;
$height = 24;
}
// make sure it's compatible with the flash player
if (!audio_is_flash_playable($node)) {
return NULL;
}
$options['soundFile'] = check_url($node->url_play);
$url = base_path() . drupal_get_path('module', 'audio') .'/players/1pixelout.swf';
$flashvars = audio_query_string_encode($options);
$output = <<<EOT
<object type="application/x-shockwave-flash" data="$url" width="$width" height="$height" >
<param name="movie" value="$url" />
<param name="wmode" value="transparent" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="FlashVars" value="$flashvars" />
<embed src="$url" flashvars="$flashvars" width="$width" height="$height" />
</object>
EOT;
return $output;
}
?>
<?php
//titles are now ignored by specific node type when they are anomalous in the design
$vars['breadcrumb_title'] = $vars['title'];
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if (in_array($node->type, array('page', 'story'))) {
$vars['title'] = '';
}
}
?>
What happens when you remove the function phptemplate_audio_1pixelout_node_player? Does the problem go away?
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
Hey, I think I may have found the problem.
Searched drupal and it turns out the error given is "almost always due to an outdated module." I updated the audio module and sure enough, it's pretty much working. The only problem is now the player itself isn't showing up in the table view. I get no error, but just get a "click to play" link instead of the player. My administration page is also telling me that I need to run the database update script and update to the newest version of drupal. I'm wondering if that won't fix the problem. Any advice on the best way to proceed?
Well, I'm a whole lot closer and I think I might have found a solution I like anyway.
I updated to Drupal 5.3 and updated several out of date modules (that update status module is pretty handy!).
Now I don't get any errors from the functions we added in php template. However, I'm not sure where to put the code to change the size of the player. BUT..
With the newer updates, I can pick which player I want for different views, so putting the button player in the table view works well. I think I'd like to have the 1pixelout player there, but I'm not decided on that yet.
Anyway, things are working better. If you can give me some help as to where to put the code to call the small player, that would be awesome. Thanks!
Put the code we had from before in the template.php file. That as my fault for assuming you were using the newest release version of the module. That's what that code was based on.
When ever problems pop up it's a good idea to make sure you are running the newest versions of the modules you have.
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
Right, I know where the majority of the code to theme the colors and the size, but where do I put the small code that calls the small player?
I just want the small player on the podcast page with the table view, do I put it in the content section there? Where does that code go?
In the views setup just tell it to use the XSPF button player. Then, it should show on that list.
Or, are you asking how to theme that player?
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
You gave me the code to merge the functions of theming the colors of the 1pixelout player and the size of it. I want a smaller 1pixelout player in the view, not the button player. You gave me the php code to call the small player, but I'm not sure where to put that code. Where does it go for a view like this? Does that make sense?
I gotcha. I'd have to go take a look at the code. I'll get back to you on that. Look for something later this week.
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
Thanks, no rush. I appreciate it.
I notice that it's possible to make the flash player smaller? How would one go about doing this, but keeping it large for some pages and smaller for others?
www.iamanoffering.com/blog