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: [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: [chris] Video player question

By s2smedia - August 11, 2010

YOUR THE MAN!!!

works perfect!

just one question...

is there anyway we can add something to the end of the link?

index2.php?video_gallery_num=4&video_upload_index=0

to look like:
index2.php?video_gallery_num=4&video_upload_index=0&autoplay=true

there is a field in the flash script, just above where it loads video file

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


it would be awesome if I can get that to autoplay only when they are to click on a video in the video player

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