Video player question

8 posts by 2 authors in: Forums > CMS Builder
Last Post: August 11, 2010   (RSS)

By s2smedia - August 10, 2010

ok i have made a simple video gallery using a flash file and cms builder..

http://www.vandrewalbanomilam.com/test/media.php

this page and flash player uses this code to play a video:

<script type="text/javascript">
swfobject.embedSWF("player.swf", "player", "466", "280", "9.0.0","",{
// flash vars
"player.start.paused": "true",
"player.start.buffering": "true",
<?php foreach ($video_galleryRecords as $record): ?>
<?php foreach ($record['video_upload'] as $upload): ?>
"player.start.resource": "<?php echo $upload['urlPath'] ?>"
<?php endforeach ?>
<?php break; ?>
<?php endforeach ?>
},{
// params
bgcolor:"#000000",
allowfullscreen:"true"
});


I have it set so it inititally loads whatever the first record is..
I need somehow a way so when you click on another video link... it refreshes the page and now makes that video load..

Re: [s2smedia] Video player question

By Chris - August 10, 2010

Hi s2smedia,

Can you please post the complete PHP source code for that page?
All the best,
Chris

Re: [chris] Video player question

By s2smedia - August 11, 2010

<?PHP function textLimit($string, $length, $replacer = '...')
{
if(strlen($string) > $length)
return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;

return $string;
}

?>
<?php


// load viewer library
$libraryPath = 'admin/lib/viewer_functions.php';
$dirsToCheck = array('XXXX');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($video_galleryRecords, $video_galleryMetaData) = getRecords(array(
'tableName' => 'video_gallery',
));

?>
<?php


// load viewer library
$libraryPath = 'admin/lib/viewer_functions.php';
$dirsToCheck = array('XXXXXX');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'perPage' => '5',
'orderBy' => 'date DESC',
));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The Van Drew Team for Change : Jeff Van Drew, Nelson Albano, Matt Milam</title>
<meta name="description" content="Nelson Albano and Matt Milam understand the challenges South Jersey’s families are facing.">
<meta name="keywords" content="South Jersey Senators, Jeff Van Drew, Nelson Albano, Matt Milam, New Jersey Senator, NJ Senate, Cape May County Senators">
<meta name="copyright" content="2010">
<meta name="author" content="Sight2Site Media">
<meta name="email" content="contact@s2smedia.net">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="resources/js/swfobject.js"></script>
<script type="text/javascript" src="resources/js/fixMouseWheel.min.js"></script>
<script type="text/javascript">
swfobject.embedSWF("player.swf", "player", "466", "280", "9.0.0","",{
// flash vars
"player.start.paused": "true",
"player.start.buffering": "true",
<?php foreach ($video_galleryRecords as $record): ?>
<?php foreach ($record['video_upload'] as $upload): ?>
"player.start.resource": "<?php echo $upload['urlPath'] ?>"
<?php endforeach ?>
<?php break; ?>
<?php endforeach ?>
},{
// params
bgcolor:"#000000",
allowfullscreen:"true"
});
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>

<body onload="MM_preloadImages('images/menu_dwn_r1_c1.jpg','images/menu_dwn_r1_c2.jpg','images/menu_dwn_r1_c3.jpg','images/menu_dwn_r1_c4.jpg','images/menu_dwn_r1_c5.jpg','images/menu_dwn_r1_c6.jpg')">
<table width="785" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" style="padding:10px 10px 0px 10px"><img src="images/header_images2_r1_c1.png" alt="the Van Drew Team For Change" width="269" height="26" /></td>
<td align="center" valign="top" style="padding:10px 10px 0px 10px"><img src="images/header_images2_r1_c3.png" width="181" height="26" /></td>
<td align="right" valign="top" style="padding:10px 10px 0px 10px"><a href="http://www.vandrewalbanomilam.com" target="_blank"><img src="images/header_images2_r1_c5.png" alt="vandrewalbanomilam.com" width="246" height="26" border="0" /></a></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><img src="images/br_line2.jpg" width="785" height="6" /></td>
</tr>

<tr>
<td height="729" colspan="3" align="center" valign="top" id="main"><table width="768" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="left" valign="top"><img src="images/masthead.jpg" alt="Matt Milam Nelson Albano Jeff Van Drew" width="768" height="212" /></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><a href="index2.php"><img src="images/menu_up_r1_c1.jpg" alt="Home" width="101" height="50" border="0" id="Image1" onmouseover="MM_swapImage('Image1','','images/menu_dwn_r1_c1.jpg',1)" onmouseout="MM_swapImgRestore()" /></a><a href="jeffvandrew.php"><img src="images/menu_up_r1_c2.jpg" alt="Jeff" width="90" height="50" border="0" id="Image2" onmouseover="MM_swapImage('Image2','','images/menu_dwn_r1_c2.jpg',1)" onmouseout="MM_swapImgRestore()" /></a><a href="nelsonalbano.php"><img src="images/menu_up_r1_c3.jpg" alt="Nelson" width="120" height="50" border="0" id="Image3" onmouseover="MM_swapImage('Image3','','images/menu_dwn_r1_c3.jpg',1)" onmouseout="MM_swapImgRestore()" /></a><a href="mattmilam.php"><img src="images/menu_up_r1_c4.jpg" alt="Matt" width="98" height="50" border="0" id="Image4" onmouseover="MM_swapImage('Image4','','images/menu_dwn_r1_c4.jpg',1)" onmouseout="MM_swapImgRestore()" /></a><a href="ourplan.php"><img src="images/menu_up_r1_c5.jpg" alt="Our Plan" width="128" height="50" border="0" id="Image5" onmouseover="MM_swapImage('Image5','','images/menu_dwn_r1_c5.jpg',1)" onmouseout="MM_swapImgRestore()" /></a><a href="action.php"><img src="images/menu_up_r1_c6.jpg" alt="Action" width="110" height="50" border="0" id="Image6" onmouseover="MM_swapImage('Image6','','images/menu_dwn_r1_c6.jpg',1)" onmouseout="MM_swapImgRestore()" /></a><img src="images/menu_dwn_r1_c7.jpg" alt="Media" width="121" height="50" id="Image7" /></td>
</tr>

<tr>
<td colspan="3" align="left" valign="top"><table width="768" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="499" align="left" valign="top" style="padding:6px 0px 0px 0px"><table width="768" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><img src="images/media.jpg" alt="Media" width="768" height="46" /></td>
</tr>
<tr>
<td height="850" align="left" valign="top" bgcolor="#0D3D77" style="padding:15px 15px 6px 15px">
<div><a name="news"></a><img src="images/videogallery.gif" width="738" height="46" alt="Video Gallery" /></div>
<table width="738" border="0">
<tr>
<td width="666" align="left" valign="top"><div id="flash2"><div id="player"></div></div></td>
<td width="400" height="280" align="left" valign="top"><div id="flash3"><?php foreach ($video_galleryRecords as $record): ?>
<?php foreach ($record['video_thumbnail'] as $upload): ?>
<div id="videothumb">
<table width="254" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="64" align="left" valign="top" style="padding:0px 0px 0px 5px"><a href="#" style="color:#FFF; text-decoration:underline"><img src="<?php echo $upload['urlPath'] ?>" width="64" height="43" id="flash2"/></a></td>
<td align="left" valign="top" style="padding:0px 5px 0px 8px"><b style="text-transform:uppercase"><a href="#" style="color:#FFF; text-decoration:underline"><?php echo $record['video_title'] ?></a></b><br />
<?php echo textLimit($record['video_description'], 60) ?></td>
</tr>
</table>
</div>
<?php endforeach ?>
<?php endforeach ?>
</div>
</td>
</tr>
</table>


<div style="margin:30px 0px 8px 0px"><a name="news"></a><img src="images/newsarchives.gif" width="738" height="46" alt="News Archives" /></div>
<?php foreach ($newsRecords as $record): ?>
<div id="news" style="padding:0px 20px 0px 20px"><i style="color:#999999; font-size:13px"><?php echo date("n.j.y", strtotime($record['date'])) ?></i><br />
<div style="padding:0px 0px 5px 0px"><b style="font-size:16px"><a href="<?php echo $record['_link'] ?>" style="color:#FFF; text-decoration:underline"><?php echo $record['headline'] ?></a></b></div>

<i><?php echo textLimit($record['news_story'], 250) ?></i> <a href="<?php echo $record['_link'] ?>" style="font-size:12px; color:#A1020E; font-weight:normal">read more</a></div>
<?php endforeach ?>
<div style="color:#FFF; font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:0px 20px 0px 20px">
<?php if ($newsMetaData['prevPage']): ?>
<a href="<?php echo $newsMetaData['prevPageLink'] ?>#news" style="color:#FFF; text-decoration:underline">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

- page <?php echo $newsMetaData['page'] ?> of <?php echo $newsMetaData['totalPages'] ?> -

<?php if ($newsMetaData['nextPage']): ?>
<a href="<?php echo $newsMetaData['nextPageLink'] ?>#news" style="color:#FFF; text-decoration:underline">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?></div>

</td>
</tr>
<tr>
<td height="35" align="left" valign="top" style="background-image:url(images/bar_bg.jpg); background-repeat:repeat-x">&nbsp;</td>
</tr>
</table></td>

</tr>


</table></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><div id="footer">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="46%" align="left" valign="top"><img src="images/facebook.gif" width="126" height="30" alt="Become a Fan on Facebook" /></td>
<td width="54%" align="right" valign="top"><a href="index2.php">HOME</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="jeffvandrew.php">JEFF</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="nelsonalbano.php">NELSON</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="mattmilam.php">MATT</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="ourplan.php">OUR PLAN</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="action.php">ACTION</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="media.php">MEDIA</a><br />
Paid for by Jeff Van Drew for the 1st District</td>
</tr>
</table>
</div></td>
</tr>

</table></td>
</tr>

</table>
</body>
</html>

Re: [s2smedia] Video player question

By Chris - August 11, 2010

Hi s2smedia,

Here's one solution: pass the record number and the upload index in the query string. I noticed you're using pagination on that page, so I've added code to preserve the "page" query string if it's supplied. New code in red:

<?php foreach ($video_galleryRecords as $record): ?>
<?php if (@$_REQUEST['video_gallery_num'] && $_REQUEST['video_gallery_num'] != $record['num']) { continue; } ?>
<?php $video_upload_index = -1; ?>

<?php foreach ($record['video_upload'] as $upload): ?>
<?php $video_upload_index++; ?>
<?php if (@$_REQUEST['video_upload_index'] && $_REQUEST['video_upload_index'] != $video_upload_index) { continue; } ?>

"player.start.resource": "<?php echo $upload['urlPath'] ?>"
<?php if (!@$_REQUEST['video_upload_index']) { break; } ?>
<?php endforeach ?>
<?php if (!@$_REQUEST['video_gallery_num']) { break; } ?>
<?php endforeach ?>


<td width="400" height="280" align="left" valign="top"><div id="flash3">
<?php foreach ($video_galleryRecords as $record): ?>
<?php $base_url = (@$_REQUEST['page'] ? 'page='.$_REQUEST['page'].'&' : ''); ?>
<?php $video_upload_index = -1; ?>

<?php foreach ($record['video_thumbnail'] as $upload): ?>
<?php $video_upload_index++; ?>
<?php $url = $base_url . 'video_gallery_num=' . $record['num'] . '&video_upload_index=' . $video_upload_index ?>

<div id="videothumb">
<table width="254" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="64" align="left" valign="top" style="padding:0px 0px 0px 5px"><a href="#" style="color:#FFF; text-decoration:underline"><img src="<?php echo $upload['urlPath'] ?>" width="64" height="43" id="flash2"/></a></td>
<td align="left" valign="top" style="padding:0px 5px 0px 8px"><b style="text-transform:uppercase">
<a href="<?php echo $url ?>" style="color:#FFF; text-decoration:underline"><?php echo $record['video_title'] ?></a></b><br />
<?php echo textLimit($record['video_description'], 60) ?></td>
</tr>
</table>
</div>
<?php endforeach ?>
<?php endforeach ?>
</div></td>


Does that work for you?

Another solution would be to see if you can tell your flash app to load a new URL. You'd have to check its API documentation to figure out if/how to do that from JavaScript.

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [s2smedia] Video player question

By Chris - August 11, 2010 - edited: August 11, 2010

Hi s2smedia,

Sure thing. Just change this:

"player.start.paused": "true",

...to this:

<?php if (@$_REQUEST['autoplay']): ?>
"player.start.paused": "false",
<?php else: ?>
"player.start.paused": "true",
<?php endif ?>


And change this:

<?php $url = $base_url . 'video_gallery_num=' . $record['num'] . '&video_upload_index=' . $video_upload_index ?>

...to this:

<?php $url = $base_url . 'video_gallery_num=' . $record['num'] . '&video_upload_index=' . $video_upload_index . '&autoplay=true' ?>

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Video player question

By s2smedia - August 11, 2010

hmm getting error:

Parse error: syntax error, unexpected ';', expecting ':' in /home1/kenncom1/public_html/vandrewalbanomilam/test/includes/sidebar.php on line 56


CODE:

<script type="text/javascript" src="resources/js/swfobject.js"></script>
<script type="text/javascript" src="resources/js/fixMouseWheel.min.js"></script>
<script type="text/javascript">
swfobject.embedSWF("player.swf", "player", "252", "180", "9.0.0","",{
// flash vars
<?php foreach ($video_galleryRecords as $record): ?>
<?php if (@$_REQUEST['video_gallery_num'] && $_REQUEST['video_gallery_num'] != $record['num']) { continue; } ?>
<?php $video_upload_index = -1; ?>
<?php foreach ($record['video_upload'] as $upload): ?>
<?php $video_upload_index++; ?>
<?php if (@$_REQUEST['video_upload_index'] && $_REQUEST['video_upload_index'] != $video_upload_index) { continue; } ?>
<?php if (@$_REQUEST['autoplay']): ?>
"player.start.paused": "false",
<?php else ?>
"player.start.paused": "true",
<?php endif ?>
"player.start.resource": "<?php echo $upload['urlPath'] ?>"
<?php if (!@$_REQUEST['video_upload_index']) { break; } ?>

<?php endforeach ?>
<?php if (!@$_REQUEST['video_gallery_num']) { break; } ?>
<?php endforeach ?>
},{

Re: [s2smedia] Video player question

By Chris - August 11, 2010

Oops! Sorry. The else should have a colon after it, like this:

<?php else: ?>

I've also updated my earlier post to be correct.
All the best,
Chris