?
Solved

Flash movie with XML playlist

Posted on 2006-05-02
18
Medium Priority
?
350 Views
Last Modified: 2012-05-05
I'm passing a session id to a flash movie via php to use as the name of a xml playlist file. I'm using a php script to rewrite the xml playlist based on what link a user clicks on. In other words, each user generates a new xml file based on their session id and link selection. I'm naming the xml file the user's session id to prevent users from sharing a playlist file. My question is:  How can I load the session id and append it to the .xml suffix within my flash actionscript?

I have tried:

x.load("$sess.xml");
where $sess is the session_id,

and

x.load("$sess"); where $sess is the session_id.xml

Neither seems to work in the movie. My php is generating the xml file okay...

Any suggestions?
0
Comment
Question by:dwimberley76
  • 8
  • 8
  • 2
18 Comments
 
LVL 3

Expert Comment

by:BishopNeo
ID: 16592341
try x.load($sess + ".xml");

Sorry for the short answer, it's late and I've put in too many hours :)
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16593083
Hi,

here is the reply in detail:
-----------------

1.
lets assume php that return the session ID to flash, has the name "forFlash.php"

2.
first of all, you should test the output of this php on browser, if it gets called directly on browser output should be in simple text format as similar to the querystring.. means, a variable name with its value.

for example: if it I typed in browser address bar " http://www.mydomain.com/forFlash.php"
output should be like this:
-----------
&phpVar=sessonValue&
-----------
Note: "&" has been used to avoid the any extra space or line break in the end. so that flash can easily read it properly.

now theflash part:

3.
Put this code on a frame of your FLA where you want to load the above php variable..
---------
var myXML = new XML();
myXML.ignoreWhite = true;
var myLoadVars = new LoadVars();
myLoadVars.onLoad = function(success)
{
      if (success)
      {
            afterSessionLoaded(this.phpVar);
      } else
      {
            trace("loading fails...");
      }
};
myLoadVars.load("http://www.mydomain.com/forFlash.php");
function afterSessionLoaded(sessionName)
{
      myXML.load(sessionName+".xml");
}
myXML.onLoad = function(success)
{
      if (success)
      {
            //do actoin on success
      } else
      {
            trace("loading fails...");
      }
};
---------------

I hope all would be clear

Rgds
Aneesh


0
 

Author Comment

by:dwimberley76
ID: 16597177
I'm using the session id variable as a query string from a link (i.e., www.mydomain.com?sess=$session_id), so it prints:
www.mydomain.com?sess=(32 random digits) in the address line of the browser. Do I need to do this differently?

Here is the flash code I'm trying to altar. I tried using your code and it didn't work, but I think I may need to change part of the existing code to work with yours.

var rtmpRoot, instance, file, type;
var x:XML = new XML();
x.ignoreWhite = true;
x.onLoad = function(success) {
      if (!success) {
            trace("Cannot load XML");
      } else {
            trace("Loaded");
            //trace(this);
            
            file = this.childNodes[0].childNodes[0].childNodes[0].toString();
            trace(file.substr(file.length - 3, 3));
            type = file.toLowerCase().substr(file.length - 3, 3);
            trace (type);

      }
};

x.load($sess + ".xml");

The last line is what I've been experimenting with. Can your code work with this existing code? It's probably an easy fix, but I don't often work with actionscript, so I'm sort of learning as I go.

Thanks!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:BishopNeo
ID: 16597255
if you trace $sess what does it return?
0
 

Author Comment

by:dwimberley76
ID: 16597297
I'm not sure how to trace... I tried the above method in the browser, but it doesn't work because the php code that passes the variable is just part of a dynamic link on the page. When I open the page in the browser, it just shows the regular page content including the links. Not sure if I'm making sense...
0
 
LVL 3

Expert Comment

by:BishopNeo
ID: 16597543
trace(":SESSIONID: " + $sess);

Assuming the actual variable name is $sess.  From reading your post above:
I'm using the session id variable as a query string from a link (i.e., www.mydomain.com?sess=$session_id), so it prints:
www.mydomain.com?sess=(32 random digits) in the address line of the browser. Do I need to do this differently?

I have to ask, how do you pass the session id to Flash?
0
 

Author Comment

by:dwimberley76
ID: 16597621
That's what I'm trying to figure out! I've tried embedding the variable in the object code on the page where the flash movie is embedded, (i.e., <param name="sess" value="<?php echo "$sess"; ?>">) but not sure if it's actually passing the variable or not.
0
 
LVL 3

Expert Comment

by:BishopNeo
ID: 16597709
Ah ha!

You need to pass the session id using flashvars in the <object> and <embed> tags.  For example:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="577" height="197">
      <param name="movie" value="mySwf.swf">
      <param name="quality" value="high">
      <PARAM NAME="flashvars" VALUE="session_id=<?php echo "$sess"; ?>">
      <embed src="Flash/mySwf.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="577" height="197"></embed>
    </object>


THEN the flash side become easier, all you need to do is call x.load(session_id + ".xml");

Make sense?

0
 

Author Comment

by:dwimberley76
ID: 16597771
Would the actionscript look like this, then?

var rtmpRoot, instance, file, type;
var x:XML = new XML();
x.ignoreWhite = true;
x.onLoad = function(success) {
      if (!success) {
            trace("Cannot load XML");
      } else {
            trace("Loaded");
            //trace(this);
            
            file = this.childNodes[0].childNodes[0].childNodes[0].toString();
            trace(file.substr(file.length - 3, 3));
            type = file.toLowerCase().substr(file.length - 3, 3);
            trace (type);

      }
};

x.load(session_id + ".xml");
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16597822
Yes, it is right and should work perfectly


Rgds
Aneesh
0
 

Author Comment

by:dwimberley76
ID: 16597868
Hmmmm. Still not working. Does the flash embedding code look right?

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" width="80" height="80">
<param name="movie" value="flash_detection.swf?flashContentURL=video.php?file=<?php echo "$_GET[file]"; ?>&stat=video&altContentURL=alternate.html&contentVersion=7&contentMajorRevision=0&contentMinorRevision=0&allowFlashAutoInstall=false" />
<param name="quality" value="low" />
<param name="flashvars" value="session_id=<?php echo "$PHPSESSID"; ?>">
<embed src="flash_detection.swf?flashContentURL=video.php?file=<?php echo "$_GET[file]"; ?>&stat=video&altContentURL=alternate.html&contentVersion=7&contentMajorRevision=0&contentMinorRevision=0&allowFlashAutoInstall=false" quality="low" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="80" height="80" />
</object>
0
 
LVL 3

Expert Comment

by:BishopNeo
ID: 16597898
What is all this?
value="flash_detection.swf?flashContentURL=video.php?file=<?php echo "$_GET[file]"; ?>&stat=video&altContentURL=alternate.html&contentVersion=7&contentMajorRevision=0&contentMinorRevision=0&allowFlashAutoInstall=false"

?
0
 
LVL 3

Expert Comment

by:BishopNeo
ID: 16597920
Unless you have hundreds of swfs with unique names you will never load the file.  if those are parameters that you are passing (or trying to pass) to Flash use flashvars.  
(sorry for the douple post, hit submit too soon)
0
 

Author Comment

by:dwimberley76
ID: 16597968
The majority of those variables are used in the flash player;  it was a free download, so I'm not sure of the purpose on most of them. The file variable is something I added to call data from a database and display outside of the flash movie on the player page.
0
 

Author Comment

by:dwimberley76
ID: 16597979
Should mention that when I look at the source code on the player page after adding the session id parameter, it doesn't show up in the code for some reason...
0
 
LVL 3

Accepted Solution

by:
BishopNeo earned 2000 total points
ID: 16598055
Well, unless you have a swf named flash_detection.swf?flashContentURL=video.php?file=<?php echo "$_GET[file]"; ?>&stat=video&altContentURL=alternate.html&contentVersion=7&contentMajorRevision=0&contentMinorRevision=0&allowFlashAutoInstall=false if will never get called.  You shouldn't need anymore than:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="80" height="80">
      <param name="movie" value="flash_detection.swf">
      <param name="quality" value="high">
      <PARAM NAME="flashvars" VALUE="session_id=<?php echo "$sess"; ?>">
      <embed src="flash_detection.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="80" height="80"></embed>
    </object>

now, I don't know PHP that well so I can't speak towards the session id showing up but if should be nothing more than referencing a CGI query_string variable.
0
 

Author Comment

by:dwimberley76
ID: 16598104
Got rid of the extra crap and it worked. Thanks for all your help!
0
 
LVL 3

Expert Comment

by:BishopNeo
ID: 16598121
Welcome.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question