What is a proper way to download video first and then play it in Flash? NetStream seems to allow me only to stream video - I can't find a way to download file completely first. Is there some other file for this?
It looks like I can download the file using URLLoader, then do NetStream.play(null) and then append bytes from URLLoader using NetStream.appendBytes(...), but I get: "SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: file:///Users/Paulius/Build.swf cannot access unknown URL. No policy files granted access." Is there a workaround?
The error you have reported. It seems that flash player is unable to access to the document root folder of your web server. Place crossdomain.xml in the web server’s document root directory.
This should solve the problem you are facing.
No, I don't think that's the issue. I have no problems downloading the video using URLLoader, which does the crossdomain check. Problem is when I do this:
stream = new NetStream(connection);
// ... snip ...
video = new Video();
stream.appendBytes(videoByteArray as ByteArray); // videoByteArray is taken from URLLoader downloaded content, i.e. the video
As you can see NetStream doesn't know anything about the video, it doesn't know anything about the server, so it can not take something from crossdomain.xml.
As far as I've read, it's imposible to do what I'm doing: simply Flash security won't allow to take contents of anonymous stream (i.e. stream started with play(null)).
So my question is: how do I download video first and then play (instead of streaming) it in some other way? I couldn't find such API on NetStream itself.
Have you found a solution to make Bitmap.draw() work with NetStream.appendBytes()? I ran into the same problem and couldn't find a solution.
No, my conclusion was that it is imposible due to security sandbox restrictions. We ended up prestreaming part of video using NetStream and then simply unpausing it.