2013-04-11 28 views
2

我試圖在Adobe Flex中使用YouTube視頻。我已將視頻添加到畫布,但無法修復視頻的大小。它也呈現在全寬和高度。以下是我的代碼。無法設置YouTube視頻的修復大小

守則引擎收錄http://pastebin.com/hN3NHRpp

<mx:Canvas width="380" height="250" id="uplayer" /> 

public function init(){ 
    _uic = UIComponent(uplayer.addChild (new UIComponent())); 
    _uic.width = 380; 
    _uic.width = 250; 

    _loader = new Loader(); 
    _loader.contentLoaderInfo.addEventListener(Event.INIT, onLoadInit); 
    var request:URLRequest = new URLRequest("http://www.youtube.com/v/2030agUM_JY?version=2&autoplay=1&fs=0&hd=1"); 
    _loader.load(request); 
} 

private function onLoadInit(event:Event):void { 
         _player = _loader.content; 

       _playerObject = _player as DisplayObject; 

     //_playerObject.addEventListener("jwplayerReady", onPlayerReady); 

      // RootReference.root = _playerObject.root; 

       _uic.addChild(_loader); 
         _uic.width = 380; 
         _uic.width = 250; 
} 

回答

0

根據文檔,您需要使用YouTube播放器的setSize()方法:

在你onLoadInit()事件處理程序,你需要添加額外的事件監聽器_loader.content(或您的_player變量是同一個對象)。特別是您需要聽取onReady事件,並在onReady事件的處理程序中,您可以使用_player.setSize(380,250)設置大小。

如果您按照documentation here中給出的代碼/示例進行操作,我相信它會起作用。