/ Published in: ActionScript 3
URL: http://activeden.net/user/rondog?ref=rondog
If you ever need to take a snapshot of an FLV that is streaming, you know you cant just use bitmap.draw because you get a Security Sandbox Violation. To be specific:
SecurityError: Error #2135: Security sandbox violation: BitmapData.draw: file:///your.swf cannot access rtmp://yourStreamingServer.net. RTMP content cannot be accessed using this API. at flash.display::BitmapData/draw() at Untitled_fla::MainTimeline/takeSnapshot()
This will allow you to do it by simply disconnecting the netStream and reattaching it.
Expand |
Embed | Plain Text
function takeSnapshot():void { // vidPlayer is the instance name of your FLVPlaybackComponent var nsObj = vidPlayer.getVideoPlayer(0); nsObj.attachNetStream(null); // Take the snapshot var myBitmapData:BitmapData = new BitmapData(vidPlayer.width, vidPlayer.height); var img = myBitmapData.draw(vidPlayer); var bmp:Bitmap = new Bitmap(myBitmapData); addChild(bmp); // reattach the netstream object nsObj.attachNetStream(nsObj.netStream); }
You need to login to post a comment.
