c/fe

http://d.hatena.ne.jp/uzulla から移行しました。

UstreamPlayerをFlexに埋め込む

http://developer.ustream.tv/
色々かいてあるんだけど、オチとしては凄い簡単だった。

--コード部分
public function init():void{
	Security.allowDomain("ustream.tv")

	ustv=new Loader();
	ustv.contentLoaderInfo.addEventListener(Event.COMPLETE, onRslLoad);
	var applicationDomain:ApplicationDomain=ApplicationDomain.currentDomain;
	var loaderContext:LoaderContext=new LoaderContext();
	var request:URLRequest=new URLRequest("http://www.ustream.tv/flash/viewer.rsl.swf");
	loaderContext.applicationDomain=applicationDomain;
	ustv.load(request, loaderContext);
}
public function onRslLoad(event:Event):void
{
	var logicClass:Class=ustv.contentLoaderInfo.applicationDomain.getDefinition("tv.ustream.viewer.logic.Logic") as Class;
	viewer=new logicClass();
	viewer.display.width=400;
	viewer.display.height=300;
	viewer.createChannel("520983"); // CIDは各ページに埋め込まれているので、調べる
	holder.addChild(viewer.display);
}
--デザイン部分
<mx:UIComponent id="holder" x="0" y="0" width="400" height="300"/>

こんなに簡単に埋め込めるとは…。