I'm trying to get a bitmap/snapshot of a Wowza video stream playing on my client, like so:
var bitmapData:BitmapData = new BitmapData(view.videoPlayerComponent.width, view.videoPlayerComponent.height);
bitmapData.draw(view.videoPlayerComponent);
When I do this, I get this error message:
SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://localhost:51150/Resources/WRemoteWebCam.swf cannot access rtmp://localhost/videochat/smithkl42._default/. No policy files granted access.
I presume the error comes from not being able to locate the appropriate crossdomain.xml file. I'm not quite sure where it's looking for it, and a wireshark sniff was inconclusive, so I've tried placing one in each of the following places:
http://localhost/crossdomain.xml
http://localhost:1935/crossdomain.xml
http://localhost:51150/crossdomain.xml
I can retrieve the file successfully from each of those three locations. (I'm pretty sure that the last one wouldn't have any effect, since it's just the location of the web site which hosts the page that hosts the .swf file, but on the off chance...)
These are the contents of the file that it's grabbing in each instance:
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
And it's still throwing that same error message.
I've also followed the instructions on the Wowza forums, to turn on StreamVideoSampleAccess in the [install]\conf[appname]\Application.xml, with no joy:
<Client>
<IdleFrequency>-1</IdleFrequency>
<Access>
<StreamReadAccess>*</StreamReadAccess>
<StreamWriteAccess>*</StreamWriteAccess>
<StreamAudioSampleAccess>*</StreamAudioSampleAccess>
<StreamVideoSampleAccess>*</StreamVideoSampleAccess>
<SharedObjectReadAccess>*</SharedObjectReadAccess>
<SharedObjectWriteAccess>*</SharedObjectWriteAccess>
</Access>
</Client>
Any thoughts?
It's not a crossdomain.xml issue: Here's the relevant Adobe documentation. I think this post may also be of help.
I am using Wowza too, I had the same problem than you, here what I did:
Changed Application.xml configuration, added * for client > Access > ...
Load a crossDomain.xml file, here the piece of code I use to load http or streaming files:
var url:String = this.vVideos.selectedItem.url; var protocol:String = URLUtil.getProtocol(url).toLowerCase(); var crossDomainXmlUrl:String; if (protocol == 'rtmp' || protocol == 'rtmpt') { crossDomainXmlUrl = 'http://' + URLUtil.getServerName(url) + ':1935/crossdomain.xml'; } else { crossDomainXmlUrl = 'http://' + URLUtil.getServerName(url) + '/crossdomain.xml'; } Security.loadPolicyFile(crossDomainXmlUrl); this.videoMedia.source = url; this.videoMedia.visible = true; setTimeout(this.play,1000);
eBuildy, Adobe Flex specialists
来源:https://stackoverflow.com/questions/1215127/how-do-i-specify-a-crossdomain-policy-file-to-allow-flash-to-grab-a-bitmap-from