Are you testing this over http:// or file://

If file:// crossdomain.xml may not be in play.

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of jwebbsuccess
Sent: Friday, January 16, 2009 11:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Security sandbox violation on Bitmapdata.draw( rtmpVid ) 
despite crosspolicy.xml


Take a look at this video player; notice there is an image on screen
before the video begins playback:

http://www.huffingtonpost.com/2009/01/14/obama-on-inauguration-
you_n_157881.html

I'm trying to create similar 'preview frame' functionality in my own
custom-built Flex/AS3-based RTMP video player... I need my the player
to seek ahead to a given point in video, grab a snapshot for display
as a preview frame, then seek back to the beginning before the user
initiates playback... Or something like that.

I've already got demo code (AS2) for taking a snapshot of a video
after it has started playing. The problem is when I try to write code
to do the same thing in my AS3 player, I get sandbox violation error
as if I were running the demo SWF and my video player SWF on different
servers. Both SWFs are in document folders on my computer... The
RTMP host and I have confirmed that the permissions for using
'BitmapData.draw( obj )' on a video stream are in place (the demo
works) so I've got no idea why I'm getting the sandbox violation
error.

Can anyone help me to get a snapshot of a video stream and then return
the stream to the beginning before the user initiates playback? I've
included the FLA for the demo in Flash CS4 and CS3 format:

http://www.futurewebstudios.com/bitMapViewer2.zip

The demo code is attached separately:

-------------------------------

import flash.display.BitmapData;

var nc:NetConnection = new NetConnection();
var ns:NetStream;
var myBitmapData:BitmapData = new BitmapData( 160, 120, false,
0x00CCCCCC );
var mc_1:MovieClip = this.createEmptyMovieClip( "mc",
this.getNextHighestDepth() );

btnCap.addEventListener( "click", captureVid );
nc.connect( "rtmp://okojcizj1r.rtmphost.com/vod" );
//nc.connect( "rtmp://localhost/vod" );

nc.onStatus = function( p_o )
{
var code = p_o.code;
trace( code );
if ( code == "NetConnection.Connect.Success" )
{
playLive();
}
};

function playLive()
{
trace( "playLive" );
mc_1._x = 195;
mc_1._y = 15;

ns = new NetStream( nc );
myVideo.attachVideo( ns );
myVideo.attachAudio( ns );
ns.play( "kaye_400" );
ns.onStatus = function( p_o )
{
trace( p_o.code );
};
mc_1.attachBitmap( myBitmapData,this.getNextHighestDepth() );
}

function captureVid()
{
trace( "captureVid" );
myBitmapData.draw( myVideo );
}

-------------------------------

I've also attached a piece of the code in my video player app so you
can see what I'm trying to do; if you need to see more of the code,
let me know and I'll send it to you:

-------------------------------

public function getScreenCaptureData( seekTime:Number,
vidWidth:Number, vidHeight:Number ):Bitmap
{
var startAt:Number = _netStream.time;

trace( this + " getScreenCaptureData --> startAt: " + startAt
+ ", seekTime: " + seekTime + ", vidWidth: " + vidWidth + ",
vidHeight: " + vidHeight );

_netStream.seek( seekTime );
var tempVid:Video = new Video( vidWidth, vidHeight );
tempVid.attachNetStream( _netStream );
var bd:BitmapData = new BitmapData( vidWidth, vidHeight );
bd.draw( tempVid );
_netStream.seek( startAt );

//to be continued...

return new Bitmap();
}

-------------------------------

Thanks in advance for your help.

Reply via email to