flowplayer plugin
-
hi all, just posted this on the flowplayer forums. just made my first wordpress plugin. VERY crude one to embed flowplayer. thought i’d share it. copyleft so feel free to improve it! thanks to both Realivent.com’s lightbox plugin and Asymptomatic’s simple wordpress plugin tutorial for showing me how to do this.
TO INSTALL:
– save code below as fp4wp.php inside a fp4wp folder in the plugins folder.
– copy the flowplayer folder inside this folder too.
– in the backend go to options > miscellaneous and uncheck the option to organise uploads
– set the 2 global variables at the top of the code accordingly, for example, if your wordpress install was in your site root it would look like:
$fp4wp_uploads_path = ‘/wp-content/uploads/’;
$fp4wp_plugins_path = ‘/wp-content/plugins/’;
– go to plugins in the backend and click activate.TO USE:
– upload a media file when writing/editing a post/page.
– type [PLAYER=filename] wherever you wish to insert the player, replacing filename with the actual filename and extension.
– one set of code is embedded for mp3 files and another for the rest. just edit the options in the source below.This could obviously be greatly improved by someone who knows more about wordpress plugins but I hope someone gets some use out of it anyway!
CODE:
<?php
/*
Plugin Name: fp4wp
Plugin URI: https://renechristen.net
Description: Embed FlowPlayer in WordPress.
Version: 1.0
Author: Rene Christen
Author URI: https://renechristen.net
*/
?>
<?php
$fp4wp_uploads_path = ‘/wp-content/uploads/’;
$fp4wp_plugins_path = ‘/wp-content/plugins/’;add_filter(‘the_content’, ‘fp4wp_the_content’);
function fp4wp_the_content( $content )
{
// AUDIO
$search = “/\[PLAYER=(.*\.mp3)\]/”; // audio: mp3
preg_match_all($search, $content, $audio_matches);if (is_array($audio_matches[1]))
{
foreach ($audio_matches[1] as $filename)
{
$search = “[PLAYER=”.$filename.”]”;
$replace = fp4wp_audio($filename);
$content = str_replace ($search, $replace, $content);
}
}// VIDEO
$search = “/\[PLAYER=(.*)\]/”; // video: mp4, m4v, m4a, mov, 3gp
preg_match_all($search, $content, $video_matches);if (is_array($video_matches[1]))
{
foreach ($video_matches[1] as $filename)
{
$search = “[PLAYER=”.$filename.”]”;
$replace = fp4wp_video($filename);
$content = str_replace ($search, $replace, $content);
}
}return $content;
}function fp4wp_audio($filename) { //.mp3,
global $fp4wp_uploads_path;
global $fp4wp_plugins_path;$string = ‘<object type=”application/x-shockwave-flash” data=”‘
. $fp4wp_plugins_path . ‘fp4wp/flowplayer/FlowPlayer.swf” width=”320″ height=”22″ id=”FlowPlayer”><param name=”allowScriptAccess” value=”sameDomain” />
<param name=”movie” value=”/heart/flowplayer/FlowPlayer.swf” />
<param name=”quality” value=”high” />
<param name=”scale” value=”noScale” />
<param name=”wmode” value=”transparent” />
<param name=”flashvars” value=”config={playList:[{ url: \”
. $fp4wp_uploads_path . $filename . ‘\’, },],
showPlayListButtons: false,
loop: false,
autoPlay: false,
hideControls: false,
showFullScreenButton: false,
showMenu: false,
showLoopButton: false,
initialScale: \’orig\’,
autoBuffering: false }); fo.write(\’fp1\’);}” /></object>’;return $string;
}function fp4wp_video($filename) { //.mp4,.m4v,.m4a,.mov,.3gp
$string = ‘<object type=”application/x-shockwave-flash” data=”‘
. $fp4wp_plugins_path . ‘fp4wp/flowplayer/FlowPlayer.swf” width=”320″ height=”262″ id=”FlowPlayer”><param name=”allowScriptAccess” value=”sameDomain” />
<param name=”movie” value=”/heart/flowplayer/FlowPlayer.swf” />
<param name=”quality” value=”high” />
<param name=”scale” value=”noScale” />
<param name=”wmode” value=”transparent” />
<param name=”flashvars” value=”config={videoFile: \”
. $fp4wp_uploads_path . $filename . ‘\’},
showPlayListButtons: true,
loop: false,
autoPlay: false,
hideControls: false,
showFullScreenButton: true,
showMenu: false,
showLoopButton: false,
initialScale: \’orig\’,
autoBuffering: false }); fo.write(\’fp1\’);}” /></object>’;return $string;
}?>
- The topic ‘flowplayer plugin’ is closed to new replies.