Why am I getting this error when both Wowza and the client are on the same machine? I have fiddled with crossdomain.xml and that has not helped. Furthermore the code works fine on Flash Media Server 3 and older versions of Wowza. What do I need to change in Wowza? I have set “StreamVideoSampleAccess” to * in conf/Application.xml and still no success.
I guess if I can figure out why it says “No policy files granted access.” then I can crack it.
In Flash CS3 create a new ActionScript 3.0 movie and add a video object to the library then to the stage. Name it videoObj. Add a button to the stage and name it snapshotBut.
Add this ActionScript code:
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.media.*;
var nc:NetConnection = new NetConnection();
var ns:NetStream = null;
var snapshotTimer:Number = 0;
function ncOnStatus(infoObject:NetStatusEvent)
{
trace("nc.onStatus: "+infoObject.info.code);
if (infoObject.info.code == "NetConnection.Connect.Success")
{
ns = new NetStream(nc);
var clientObj:Object = new Object();
clientObj.nsOnStatus = function(infoObject:NetStatusEvent)
{
trace("ns.onStatus: "+infoObject.info.code);
}
clientObj.onMetaData = function(infoObject:Object)
{
trace("ns.onMetaData");
}
clientObj.onPlayStatus = function(infoObject:Object)
{
trace("ns.onPlayStatus: "+infoObject.code);
}
ns.client = clientObj;
ns.addEventListener(NetStatusEvent.NET_STATUS, clientObj.nsOnStatus);
videoObj.attachNetStream(ns);
ns.play("Extremists");
}
}
function takeSnapshot(event:MouseEvent)
{
clearInterval(snapshotTimer);
trace("takeSnapshot");
var b:BitmapData = new BitmapData(640, 360);
b.draw(videoObj);
var mc:MovieClip = new MovieClip();
addChild(mc);
mc.graphics.beginBitmapFill(b, new Matrix(), true, true);
mc.graphics.moveTo(0, 0);
mc.graphics.lineTo(0, 360);
mc.graphics.lineTo(640, 360);
mc.graphics.lineTo(640, 0);
mc.graphics.lineTo(0, 0);
mc.graphics.endFill();
}
snapshotBut.addEventListener(MouseEvent.CLICK, takeSnapshot);
nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus);
nc.connect("rtmp://localhost/fastplay");
This assume Wowza Pro is running on the same machine as Flash CS3.
I really can’t support this. I am just leaving it as an example of what works for me. I have found this to be very hard to get working reliably. Even this example gives me scaling issues which I have spent hours trying to understand.
Thanks Charlie. It was actually one line of code in my app that was preventing the frame grab. Just before grabbing the frame the code was calling
videoObj.attachNetStream(null);
. Please note that I inherited the code from a developer who has left but I’m glad that I’ve finally tracked down the problem. Thanks again for taking your time to help.