I use NetStream.appendBytes () to play local video (without server involvement) in Adobe AIR . I would like to use BitmapData.draw() to take a snapshot of the video output, but I get this error:
Error # 2123: sandbox security violation: BitmapData.draw: cannot access null. There are no policy files that provide access.
Here is a sample code:
package { import flash.display.Sprite; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; import flash.net.NetStreamAppendBytesAction; import flash.utils.ByteArray; import flash.display.BitmapData; class ByteArrayPlayer extends Sprite { private var _ns:NetStream; private var _nc:NetConnection; private var _video:Video; public function playVideo(path:String):void { _nc = new NetConnection(); _nc.connect(null); _ns = new NetStream(_nc); _video = new Video(); addChild(_video); _video.attachNetStream(_ns); _ns.play(null); _ns.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN); var file:File = new File(path); var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.READ); var bytes:ByteArray = new ByteArray(); fileStream.readBytes(bytes); _ns.appendBytes(bytes); } public function getImage(video:Video):BitmapData { var bit:BitmapData = new BitmapData(_video.width, _video.height); bit.draw(_video);
This is just an example of using code for explanation. An error occurred while calling the getImage method during video playback. The error mentions a policy file that was not found. Since the file is downloaded locally, there really is no place to host the policy file. Is there a policy setting somewhere that needs to be set, or is the BitmapData.draw function just not available when using appendBytes ?
flash actionscript-3 air adobe flash-video
Aaron
source share