Log in

View Full Version : AS3 load the path to FLV at runtime



jeaux
10-02-2008, 02:49 AM
I have a custom skin that I created that will play properly from this html:


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>video player</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '320',
'height', '240',
'src', 'video player',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'video player',
'bgcolor', '#ffffff',
'name', 'video player',
'menu', 'true',
'allowFullScreen', 'true',
'allowScriptAccess','sameDomain',
'movie', 'video player',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="240" id="video player" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="video player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="video player.swf" quality="high" bgcolor="#ffffff" width="320" height="240" name="video player" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
</body>
</html>

What I'd like to do is change the FLVplayback's source or content path at runtime from a <param> or FlashVars or whatever that's located in the html. I've tried using the DW4 interface to add a video with my skin but it seems to have problems connecting to FMS3. Ideally I would like to stream the content but if forced to use progressive download I will.

Thank you for any incite you may have,
Joe

Medyman
10-02-2008, 01:18 PM
I'm not sure what exactly your question is. Can you please rephrase?

On a related note, Lee Brimelow has some great video tutorials on video players at gotoAndLearn() (http://www.gotoandlearn.com). There are eight tutorials at the very bottom of the page related to building a video player. That might be of use to you.

There are also tutorials on dynamic loading of videos via XML, and FlashVars.

jeaux
10-02-2008, 04:12 PM
I've seen Lee's stuff and he's pretty cool. A lot of the content is for AS2 though.

As for the rephrased question. I want to change the FLV that's played when the movie loads. I've seen tuts on populating a playlist from an XML file, but that's not what I need to do. So let me better explain exactly what I'm doing.

One page will have a list of video links. All of these video will reside on my streaming server. The href for the videos will be generated by php with their videoID.


<a href="videoplayer.php?videoID=00001">Video one</a>
<a href="videoplayer.php?videoID=00002">Video two</a>

Now on the videoplayer.php file, php will access the mySQL DB and get the path to the video file. i.e. rtmp://localhost/vod/myfirstvideo.flv

How can I now pass that data to the FLVplayback component in my .swf that's on this videoplayer.php page?

In flash if you look at the parameters of an FLVplayback component there's a field for "source". I want to change this field at runtime with the aforementioned data from the php query.

Thanks

Medyman
10-02-2008, 04:32 PM
Ah, I see.

You should be able to combine the teachings of this tutorial (http://www.communitymx.com/content/article.cfm?cid=88033) and this video (http://gotoandlearn.com/play?id=77) to come up with what you need.

Post back if you have any troubles.

jeaux
10-03-2008, 04:16 AM
All I was missing was the


if(root.loaderInfo.parameters["VideoPath"] !=null)

I kept trying to publish but it wouldn't compile without the if(!= null)

I was able to implement the change without creating a FLVPlaybackpro class like the one tutorial link you provided like this.


myFLV.source = root.loaderInfo.parameters["VideoPath"];

Anyway the link to that swfobject_generator helped immensely.

I posted a similar post to actionscript.org and have yet to receive a reply. After your direction to the proper tuts to solve this problem and realizing how easy the solution was I am rather surprised at the lack of responses. I suppose maybe my description of my problem was worded oddly or something.

Many thanks for your time,
Joe