You can grab the source code here in this article and create a plug-in directly in your existing WordPress installation.
Clarification: The Video Cloud plug-in is for the WordPress.org full installation for hosting your own Web site, NOT for WordPress blog pages hosted on WordPress.com.
This plugin generates embed code in HTML format only. It does not provide JavaScript embed code which is required for our Smart Players to function. There are numerous methods for enabling JavaScript support and publishing JavaScript code snippets in Wordpress.org posts. Please refer to the Wordpress documentation for more details.
Download the source code for the plug-in and edit it as described in the comments. You must add your own Video Cloud publisher ID and the player ID for the single video player you want to use. Once you've installed the plug-in, you can use the following syntax to incorporate publishing code into your WordPress content:
[brightcove video="123456" /]
The parameter video refers to the ID of a video in your Video Cloud account. At a minimum, a video ID is all that's required if you've included default values for a player ID and player size (as described in the comments of the Plug-in Source). If you want to override the default value, you can specify a player ID with the player parameter.
The plug-in will insert the HTML version of the embed code into your WordPress content. Due to security restrictions built into WordPress, JavaScript code won't always run. If you're not already aware of them, take a minute to understand the differences between HTML and JavaScript embed codes.
The plug-in is designed to work only with a single video player that uses the Video Player template. If you want instead to use a player that uses the Chromeless Video Player template, modify the plug-in before you install it. Change this line to include the &isUI parameter:
$output .= "<embed src='http://c.brightcove.com/services/viewer/federated_f9/$player?isVid=1&publisherID=$publisher'
so that it reads:
$output .= "<embed src='http://c.brightcove.com/services/viewer/federated_f9/$player?isVid=1&isUI=1&publisherID=$publisher'
This code snippet shows how to create a Video Cloud player plug-in for the WordPress CMS that allows easy placement of videos within posts using the syntax .
<?php
/*
Plugin Name: Brightcove Video Player
Version: 1.0
Plugin URI: http://www.brightcove.com
Description: Simplifies the process of adding a Video Cloud video to a WordPress blog.
Author: Bob de Wit
Author URI: http://brightcove.active6.com
*/
//Set the publisher ID - YOU MUST SET THIS TO YOUR OWN PUBLISHER ID
$publisher = 1705665024;
//Set a default player to use - YOU MUST SET THIS TO YOUR OWN DEFAULT PLAYER
$player = 1911416499;
//Set width and height for the default video player
$width = 486;
$height = 412;
//Define default video variable
$videoid = 0;
//The actual parse content function called by the filter
//This will use the callback function BCVideo_Render to do the
//actual text replacement for the widget
function Brightcove_Parse($content)
{
$content = preg_replace_callback("/\[brightcove ([^]]*)\/\]/i", "Brightcove_Render", $content);
return $content;
}
function Brightcove_Render($matches)
{
global $video, $player, $publisher, $width, $height, $arguments;
$output = '';
$matches[1] = str_replace(array('”','″'), '', $matches[1]);
preg_match_all('/(\w*)=(.*?) /i', $matches[1], $attributes);
$arguments = array();
foreach ( (array) $attributes[1] as $key => $value )
{
// Strip out legacy quotes
$arguments[$value] = str_replace('"', '', $attributes[2][$key]);
}
//print_r( $arguments );
if (( !array_key_exists('video', $arguments) ) && ( !array_key_exists('player', $arguments) ))
{
return '<div style="background-color:#f99; padding:10px;">Brightcove Player Widget Error: Required parameter "video" or "player" is missing!</div>';
exit;
}
else
{
$video = $arguments['video'];
}
if( array_key_exists('width', $arguments) )
{
$height = $arguments['width'];
}
if( array_key_exists('height', $arguments) )
{
$height = $arguments['height'];
}
if( array_key_exists('player', $arguments) )
{
$player = $arguments['player'];
}
//$flashVars = "isVid=1&playerID=$player&publisherID=$publisher&@videoPlayer=$video";
$output .= "<embed src='http://c.brightcove.com/services/viewer/federated_f9/$player?isVid=1&publisherID=$publisher'
bgcolor='#FFFFFF'
flashVars='@videoPlayer=$video&playerID=$player&domain=embed&'
base='http://admin.brightcove.com'
name='flashObj'
width='$width'
height='$height'
seamlesstabbing='false'
type='application/x-shockwave-flash'
allowFullScreen='true'
swLiveConnect='true'
pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>
</embed>";
return $output;
}
//Add a filter hook - this registers the function for all content
//text (Pages and Posts) to search for the [CONTRIBUTOR_WIDGET] tag.
add_filter('the_content', 'Brightcove_Parse');
?>