Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

flash movie player using php variable

2:31 pm on Sep 8, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 7, 2007
votes: 0

Hey all

I need a flash video player to use on a website, but I need it to be able to read the flv video location from a database variable. So using some PHP and a MySQL database I'm going to end up with something equivalent to...

$filename = 'videos/my-video.flv';

... and I will then want to be able to call a flash video player that can read in my video location variable and show up on the website all skinned out (well just the basic flash player skin).

Can anybody help me out with some advice as to how I would go about doing this?

Thanks in advance.
4:47 pm on Sept 8, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

You're almost there. :-)

Most Flash players will import video via external XML files. All you need to do is output valid XML from your PHP. For example, let's say your embed code is using SWFObject (which it should) and you *normally* point to the video list like this.

<script type="text/javascript" src="/js/swfobject.js"></script>
<script type="text/javascript">
window.onload = function() {
if (document.getElementById('video-canvas')) {
var video = new SWFObject('\/flv\/myplayer.swf', 'video-embed', '495', '420', '6', '#ffffff');
video.addParam("wmode", "transparent");
video.addVariable("playlist", "\/somedirectory\/playlist.xml");

You'd just change the bolded line to
video.addVariable("playlist", "\/somedirectory\/your-script.php");

which would output valid XML. Most players accept movie, title, caption, and the like so you'd do

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>

Query your database, get full url, caption, etc . . .

while ($row=mysql_fetch_array($result)) {
$movie = $row['movie'];
$title = $row['title'];
$cap = $row['caption'];
echo "<movie url=\"$movie\" movietitle=\"$title\" moviecaption=\"$cap\"/>";

Then don't forget to close . . .

echo "</movies>";

It will vary from player to player, but that's how you'd most likely want to do it.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members