Some of you use the default flash player (JW FLASH PLAYER)
Some people have asked me a simple way to use a custom based flash player without pasting the embed codes everytime.
This is an easy and quick hack to play a .flv file with a custom field and a flash player.
Here is an example of my flash player, your variables will be different, so check the documentation or the developer for which ones suit your custom player.
This will needed to be added to header.php
This is based on you making a custom field called "video" and in that field you provide the direct url to the video. (a lot of sponsors will let you hotlink)
this you would add to functions.php in your theme directory
And finally how to add it to your theme.
Find
Add below it
It will only play a video if you set a url fo the video in the post, otherwise it will be ignored.
Enjoy.
Some people have asked me a simple way to use a custom based flash player without pasting the embed codes everytime.
This is an easy and quick hack to play a .flv file with a custom field and a flash player.
Here is an example of my flash player, your variables will be different, so check the documentation or the developer for which ones suit your custom player.
This will needed to be added to header.php
Code:
<script type="text/javascript" src="<? bloginfo('template_directory'); ?>/swfobject.js"></script>
this you would add to functions.php in your theme directory
Code:
function playvideo() {
global $post;
$player = get_bloginfo('template_directory').'/player.swf'; // location of my player
$video = get_post_meta($post->ID, 'video', true);
$width = '350';
$height = '290';
if ($video == true) {
print '<span id="video-'.$post->ID.'" class="flashvideo"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</span>';
print '<script type="text/javascript">
var so = new SWFObject("'.$player.'","n-'.$post->ID.'","'.$width.'","'.$height.'","7");
so.addParam("allowFullScreen", "true");
so.addVariable("MediaLink", "'.$video.'");
so.addVariable("playOnStart", "true");
so.addVariable("autoDetectMedia", "true");
so.addVariable("startVolume", "60");
so.addVariable("showPlayButton", "true");
so.addVariable("fitToPlayer", "true");
so.addVariable("imageScaleType", "1");
so.addVariable("loopMedia", "false");
so.write("video-'.$post->ID.'");
</script>';
}
}
And finally how to add it to your theme.
Find
Code:
<?php the_content('Read the rest of this entry »'); ?>
Code:
<?php playvideo();?>
Enjoy.


Comment