How can I use BitmapData.draw with NetStream.appendBytes?

a 夏天 提交于 2019-12-03 13:46:29

I think another solution is to use _ns.play(path) and not to use _ns.appendBytes().

Try set NetStream.checkPolicyFile = true before you call the play() function.

Like this:

_ns.checkPolicyFile = true;
_ns.play(null);

What the checkPolicyFile flag does is that it tells the host swf to load a policy file from the loaded swf's server. If you haven't specified that flag at loading time you will recieve a SecurityError when you try to get pixel data from the loaded stream through BitmapData.draw().

Link to Adobe resource: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#checkPolicyFile

Pixel Expander

I’ve a solution to get rid of the sandbox error when trying to draw a netstream.appendByte() content.

The SWF retrieves a sandbox because he is looking for a crossdomain file at the address specified by you :netstream.play(null). He’s looking for something that doesnt exist.

Well, the solution is to play a fake video url, like “netstream.play(http://myserv.com/video.flv)” with a genuine crossdomain file on it, and after that, you just have to load the video you want thanks to the appendBytes function.

The SWF is fooled!

As strange as it sounds, it work for me :-)

You can't take a snapshot of video or audio from an rtmp stream unless the server side settings called StreamVideoSampleAccess or StreamAudioSampleAccess is set to true or set like this StreamVideoSampleAccess/StramVideoSampleAccess. I haven't discovered a way to do this without having access to the FMS server side.

Try placing the Video object in a MovieClip and use bit.draw(_movieclipInstanceName); instead of the video object. I hope it works.

Jason Reeves

I know this question is really old... but it is still a problem that I just faced and I know others will too... So I wanted to post the link to the other Stack question where I posted the bug at Adobe and the workaround to get it to work.

Workaround for bug on a duplicate Stack Question

It looks like you are trying to call the BitmapData.draw() method on a video that isn't loaded, or when the NetStream object is null.

possible fix: wait until the NetStream.Buffer.Full NetStatus is dispatched before calling draw()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!