Based on:
JW Player 5.8
PHPmotion V3.5 - Rev 115
CentOS release 5.7 (Final) 64 bit
PHPmotion was installed not into sub directory (directly installed at /var/www/html/)
1. Download JW Player at http://www.longtailvideo.com/ and extract content
2. Create directory `jwplayer` at `/var/www/html/` (/var/www/html/jwplayer). Copy file `jwplayer.js` and `player.swf` from the JW Player downloaded earlier into the `jwplayer` folder.
3. Modify the `Now Playing` video player. Edit `/var/www/html/themes/default/templates/make_player.html`.
Replace below:
var flashvars = {};
var params = {};
var attributes = {};
flashvars.player_mode = "normal";
flashvars.playlist = "no";
flashvars.logo = "top_right";
flashvars.floating_navbar = "false";
flashvars.color_nav_bar_top = "0x478dc2";
flashvars.color_nav_bar_bottom = "0xE7EBEC";
flashvars.ads_background_color = "0x00CCFF";
flashvars.ads_border_color = "0xCCCCCC";
flashvars.scrubber_position_color = "0x6AA1CE";
flashvars.scrubber_load_color = "0x888888";
flashvars.scrubber_background_color = "0xBBBBBB";
flashvars.volume_bar_color = "0xBBBBBB";
flashvars.aspect_ratio="stretch";
params.allowfullscreen = "true";
params.allowscriptaccess = "sameDomain";
params.wmode = "transparent";
//___dynamic settings________
flashvars.flvsource = "[var.base_url]/uploads/[var.video_play]";
flashvars.preview_image = "[var.base_url]/[var.thumb_file]";
flashvars.url_logo = "[var.base_url]/images/playerlogos/logo-player.png";
flashvars.buffering_time = [var.video_buffer_time];
flashvars.autoplay = "[var.auto_play]";
flashvars.display_ads = "[var.player_defaults_ads]";
[var.player_defaults_ads_xml]
//___dynamic settings end ______
swfobject.embedSWF("[var.base_url]/player.swf", "myAlternativeContent", "560", "420", "9.0.0", false, flashvars, params, attributes);With this:
var flashvars = {};
var params = {};
var attributes = {};
flashvars.file = "[var.base_url]/uploads/[var.video_play]";
flashvars.autostart = "true";
flashvars.bufferlength = "[var.video_buffer_time]";
flashvars.stretching = "fill";
flashvars.image = "[var.base_url]/[var.thumb_file]";
flashvars.smoothing = "true";
flashvars.volume = "90";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.wmode = "transparent";
swfobject.embedSWF('[var.base_url]/jwplayer/player.swf','myAlternativeContent','560','420','9.0.115','false',flashvars, params, attributes);4. Modify the `Latest Videos` video player (Home). Edit `/var/www/html/themes/default/templates/make_player.html`.
Replace below:
var flashvars = {};
var params = {};
var attributes = {};
flashvars.player_mode = "playlist";
flashvars.display_ads = "no";
flashvars.playlist = "yes";
flashvars.playlist_xml = "[var.base_url]/playlist.php";
flashvars.logo = "top_right";
flashvars.url_logo = "[var.base_url]/images/playerlogos/logo-player.png";
flashvars.autoplay = "false";
flashvars.color_nav_bar_top = "0x478dc2";
flashvars.color_nav_bar_bottom = "0xE7EBEC";
flashvars.ads_background_color = "0x00CCFF";
flashvars.ads_border_color = "0xCCCCCC";
flashvars.scrubber_position_color = "0x6AA1CE";
flashvars.scrubber_load_color = "0x888888";
flashvars.scrubber_background_color = "0xBBBBBB";
flashvars.volume_bar_color = "0xBBBBBB";
flashvars.buffering_time = 1;
flashvars.aspect_ratio="stretch";
params.allowfullscreen = "true";
params.allowscriptaccess = "sameDomain";
swfobject.embedSWF("[var.base_url]/player.swf", "myAlternativeContent", "710", "350", "9.0.0", false, flashvars, params, attributes);With this:
var flashvars = {};
var params = {};
var attributes = {};
flashvars.playlistfile = "[var.base_url]/playlist.php";
flashvars.playlist = "right";
flashvars.showmute = "true";
flashvars.autostart = "false";
flashvars.bufferlength = 1;
flashvars.stretching = "fill";
flashvars.smoothing = "true";
flashvars.volume = "90";
params.allowfullscreen = "true";
params.allowscriptaccess = "sameDomain";
swfobject.embedSWF("[var.base_url]/jwplayer/player.swf", "myAlternativeContent", "710", "420", "9.0.115", false, flashvars, params, attributes);5. There is a playlist on the `Latest Videos` video player (Home). The playlist need to be amended to suite JW Player. Edit `/var/www/html/playlist.php`. Replace the whole file with the code below (for this sequence, look for 'print' syntax and replace symbol '[' to '<', and ']' to '>'):
include_once ('classes/config.php');
//____get video limit________
function GetVideoLimit() {
$limit = (is_numeric($_GET['limit']))?$_GET['limit']:12;
return $limit;
}
//____get the type $sql________
function GetVideoType() {
switch($_GET['type']) {
case 'featured':
$add_sql = " AND featured = 'yes'";
break;
case 'promoted':
$add_sql = " AND promoted = 'yes'";
break;
}
return $add_sql;
}
//____get search query_________
function GetVideoSearch() {
if($_GET['search'] != '') {
$keywords = str_replace('+',' ',$_GET['search']);
$keywords = str_replace('%20',' ',$keywords);
$keywords = str_replace('%26','&',$keywords);
$safety = array('UNION','=',"'",'?');
$keywords = str_replace($safety,'',$keywords);
$search = " AND (title LIKE '%$keywords%' OR tags LIKE '%$keywords%' OR description LIKE '%$keywords%')";
return $search;
} else {
return;
}
}
//____some cleanup___________
function CleanTitle($txt = '') {
$txt = trim($txt);
$txt = str_replace('"',"",$txt);
$txt = str_replace("'","",$txt);
$txt = str_replace('?','',$txt);
return $txt;
}
//____run sql query__________
$limit = GetVideoLimit();
$search = GetVideoSearch();
$type = ($search == '')?GetVideoType():''; //set type only if search is blank
$sql = "SELECT indexer, video_id, title, description, video_length
FROM videos
WHERE approved = 'yes'
AND public_private = 'public'
AND video_type = 'uploaded'
$type $search
ORDER BY RAND()
LIMIT $limit";
$query = @mysql_query($sql);
//____start xml file headers____________
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: 0");
print "[rss version="\"2.0\"" media="\"http://website.com/media/\""]\n";
print "[channel]\n";
print "[title]JW Player Playlist[/title]\n";
//_____loop through all results____________
while($result = @mysql_fetch_array($query)) {
$title = CleanTitle($result['title']);
$title_seo = CleanTitle($result['title_seo']);
$vid = $result['indexer'];
$file_name = $result['video_id'];
$external_url = $config["site_base_url"].'/videos/'.$vid.'/'.$title_seo;
$source_url = $config["site_base_url"].'/uploads/'.$file_name.'.flv';
$thumb_path = $base_path.'/uploads/player_thumbs/'.$file_name.'.jpg';
$source_path = $base_path.'/uploads/'.$file_name.'.flv';
$desc = $result['description'];
$video_length = $result['video_length'];
//cant find big thumb file
if(file_exists($thumb_path)) {
$thumb_url = $config["site_base_url"].'/uploads/player_thumbs/'.$file_name.'.jpg';
} else {
$thumb_url = $config["site_base_url"].'/uploads/thumbs/'.$file_name.'.jpg';
$thumb_path = $base_path.'/uploads/thumbs/'.$file_name.'.jpg';
}
//only list if the video file and imagae exist
if(file_exists($source_path) && file_exists($thumb_path)) {
print "[item]\n";
print "[title]$title[/title]\n";
print "[link]$external_url\n";
print "[description]$desc[/description]\n";
print "[media:content url="\"$source_url\"" duration="\"$video_length\""]\n";
print "[media:thumbnail url="\"$thumb_url\""]\n";
print "[/media:thumbnail][/media:content][/item]\n";
}
}
print "[/channel]\n";
print "[/rss]";That is all, now try to play your video and the playlist using the JW Player, you can purchase the JW Player if you want more extra features. Have fun and play safe lads.


