PDA

View Full Version : Feeding a video file directly to NetStream.play() through PHP


RockerMike
02-22-2008, 01:19 AM
Hello

This might be a bit of a weird question, but I'm wondering if anyone on here has experience with feeding data for a movie file directly from a php script to a Flash swf?

Actually, I'm pretty new to flash. This is what I've got so far:

------------------------------------------------------
// initialize the net connection
connection = new NetConnection();
connection.connect(null);

// initialize the net stream
stream = new NetStream(connection);

// set up this movie clip to be able to respond to events frmo the net stream
stream.client = this;
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

// create our video
video = new Video();
video.x = 0;
video.y = 0;
addChild(video);

// set it up
video.attachNetStream(stream);

movieName = "http://www.mydomain.com/getmoviedata.php";
stream.play( movieName );
------------------------------------------------------

My php script basically loads up a file with fopen, fread, and then echo's the data out.

So after all of that, my question is, should this work?
From one of the Adobe developer blogs I read, I know that NetStream.play() doesn't pay attention to the file extension. But will it read from a stream?

(I tried it, and it just stalled. No Flash warnings, no PHP errors, not that I'd see them. I'm looking for something a little more official, I guess.)

RockerMike
02-22-2008, 09:30 PM
In case anyone was interested, I figured this out.
I basically had to do what this link told me, in php, instead of using echo.
There's a code sample in the comments towards the middle of the page, added by a user, not officially.

http://ca3.php.net/manual/en/function.fpassthru.php