Posted By

rondog on 12/09/09


Tagged

error flv video streaming draw bitmap component FLVPlayback rtmp 2135


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

thastyle


Bitmap.draw with FLVPlayback component using a Streaming RTMP source


 / 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.

  1. function takeSnapshot():void
  2. {
  3. // vidPlayer is the instance name of your FLVPlaybackComponent
  4. var nsObj = vidPlayer.getVideoPlayer(0);
  5. nsObj.attachNetStream(null);
  6.  
  7. // Take the snapshot
  8. var myBitmapData:BitmapData = new BitmapData(vidPlayer.width, vidPlayer.height);
  9. var img = myBitmapData.draw(vidPlayer);
  10. var bmp:Bitmap = new Bitmap(myBitmapData);
  11. addChild(bmp);
  12.  
  13. // reattach the netstream object
  14. nsObj.attachNetStream(nsObj.netStream);
  15. }

Report this snippet  

You need to login to post a comment.