homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

flash movie player using php variable
Robert Poole

5+ Year Member

Msg#: 4198511 posted 2:31 pm on Sep 8, 2010 (gmt 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.



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

Msg#: 4198511 posted 4:47 pm on Sep 8, 2010 (gmt 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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved