Posted By

rondog on 12/09/09


error flv video streaming draw bitmap component FLVPlayback rtmp 2135

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Bitmap.draw with FLVPlayback component using a Streaming RTMP source

 / Published in: ActionScript 3


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:// 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);
  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);
  13. // reattach the netstream object
  14. nsObj.attachNetStream(nsObj.netStream);
  15. }

Report this snippet  

You need to login to post a comment.