2011-12-12 3 views
0

thumbWindow 팝업을 통해 videoDisplay를 엽니 다. 엄지를 클릭하면 비디오를 재생합니다. 원하는 것은 내 팝업의 크기를 조정하고 내부의 비디오를 원래대로 유지하는 것입니다. 종횡비는 늘어나지 않습니다 ...크기 변경 PopUp 비디오의 종횡비 유지 flex :

어떤 아이디어?

고맙습니다.

<?xml version="1.0" encoding="utf-8"?> 
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      close="CloseWindow(event)" > 
<fx:Declarations> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
</fx:Declarations> 

<fx:Script> 
    <![CDATA[ 
     import mx.events.CloseEvent; 
     import mx.events.ResizeEvent; 
     import mx.managers.PopUpManager; 


     [Bindable]public var mediaServerUrl:String; 
     [Bindable]public var videoFolder:String; 
     [Bindable]public var filename:String; 
     [Bindable]public var comments:String; 


     private var ns:NetStream; 
     private var nc:NetConnection; 
     private var video:Video; 
     private var meta:Object; 

     private function ns_onMetaData(item:Object):void { 
      trace("meta"); 
      meta = item; 
      // Resize Video object to same size as meta data. 
      video.width = item.width; 
      video.height = item.height; 
      // Resize UIComponent to same size as Video object. 
      myVid.width = video.width; 
      myVid.height = video.height; 

     } 

     private function fetch_rec():void { 
      var nsClient:Object = {}; 
      nsClient.onMetaData = ns_onMetaData; 


      nc = new NetConnection(); 
      nc.connect(null); 
      ns = new NetStream(nc); 
      ns.client = nsClient; 

      video = new Video(myVid.width,myVid.height); 
      video.attachNetStream(ns); 
      video.smoothing=true; 
      myVid.addChild(video); 
      ns.play(mediaServerUrl+"/"+videoFolder+"/"+filename+".flv"); 

     } 

     protected function CloseWindow(event:CloseEvent):void 
     { 
      ns.close(); 
      nc.close(); 
      PopUpManager.removePopUp(this); 

     } 

    ]]> 
</fx:Script> 

<mx:VideoDisplay id="myVid" visible="true" x="0" bottom="50" width="100%" height="100%" 
       maintainAspectRatio="true" 
       autoPlay="true" 
       creationComplete="fetch_rec()" 
       playheadUpdate="progBar.setProgress(myVid.playheadTime,myVid.totalTime)"/> 

<mx:ProgressBar id="progBar" left="10" right="10" bottom="60" height="10" label="" mode="manual"/> 
<s:Label x="10" bottom="30" text="Σχόλια:"/> 

<s:Label x="10" bottom="10" text="{comments}"/></s:TitleWindow> 

내가이 팝업을 호출 : : 여기 내 때에 popUp입니다

protected function launchPopUp(event:MouseEvent):void 
     { 
      if(list.selectedItem){ 
       win = new ViewVideoPopUp(); 
       win.width = this.width; 
       win.height = this.height; 

       //give what is needed to play the video selected 
       win.videoFolder = videoFolder;    // the video's folder name 
       win.mediaServerUrl = mediaServerUrl;  // the media server url 
       win.filename = list.selectedItem.filename; // the file to be played 
       win.comments = list.selectedItem.comments; // the comments left for that 
       win.title = list.selectedItem.name+" στις "+list.selectedItem.date; //title of the window 

       this.addEventListener(ResizeEvent.RESIZE, window_resize); 
       PopUpManager.addPopUp(win,this,true); 
       PopUpManager.centerPopUp(win); 

      } 
     } 

답변

0

EDIT (12/15) : OK, 난 당신의 코드를 시도하고의 화면 비율을 강제하는 방법을 추가 부모 컨테이너의 종횡비에 기반한 비디오. VideoDisplay 구성 요소 주위에 HGroup을 배치하고이를 사용하여 비디오의 크기를 결정해야합니다. 또한 창과 비디오의 크기가 다른 경우 비디오를 팝업 중앙에 배치합니다.

<?xml version="1.0" encoding="utf-8"?> 
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      close="CloseWindow(event)" autoLayout="true"> 
<fx:Script> 
    <![CDATA[ 
     import mx.events.CloseEvent; 
     import mx.events.ResizeEvent; 
     import mx.managers.PopUpManager; 


     [Bindable]public var mediaServerUrl:String; 
     [Bindable]public var videoFolder:String; 
     [Bindable]public var filename:String; 
     [Bindable]public var comments:String; 


     private var ns:NetStream; 
     private var nc:NetConnection; 
     private var video:Video; 
     private var meta:Object; 

     private function ns_onMetaData(item:Object):void { 
      trace("meta"); 
      meta = item; 

      var vidAspectRatio:Number = item.width/item.height; 
      var titleWindowAspectRatio:Number = vidContainer.width/vidContainer.height; 

      // Resize Video object to same size as meta data. 
      if (vidAspectRatio < titleWindowAspectRatio) // TitleWindow too wide 
      { 

       video.height = vidContainer.height; 
       video.width = video.height * vidAspectRatio; 
      } 
      else if (vidAspectRatio > titleWindowAspectRatio) // TitleWindow too tall 
      { 
       video.width = vidContainer.width; 
       video.height = video.width/vidAspectRatio; 
      } 
      else // TitleWindow and Video have same aspect ratio and fits just right 
      { 
       video.width = vidContainer.width; 
       video.height = vidContainer.height; 
      } 

      // Resize UIComponent to same size as Video object. 
      myVid.width = video.width; 
      myVid.height = video.height; 

     } 

     private function fetch_rec():void { 
      var nsClient:Object = {}; 
      nsClient.onMetaData = ns_onMetaData; 

      nc = new NetConnection(); 
      nc.connect(null); 
      ns = new NetStream(nc); 
      ns.client = nsClient; 

      video = new Video(myVid.width,myVid.height); 
      video.attachNetStream(ns); 
      video.smoothing=true; 
      myVid.addChild(video); 

      ns.play("../swf/barsandtone.flv"); 
     } 

     protected function CloseWindow(event:CloseEvent):void 
     { 
      ns.close(); 
      nc.close(); 
      PopUpManager.removePopUp(this); 

     } 

    ]]> 
</fx:Script> 
<s:HGroup id="vidContainer" verticalAlign="middle" horizontalAlign="center" height="100%" width="100%" bottom="50" > 
    <mx:VideoDisplay id="myVid" visible="true" 
        autoPlay="true" 
        creationComplete="fetch_rec()" 
        playheadUpdate="progBar.setProgress(myVid.playheadTime,myVid.totalTime)"/> 
</s:HGroup> 

<mx:ProgressBar id="progBar" left="10" right="10" bottom="60" height="10" label="" mode="manual"/> 
<s:Label x="10" bottom="30" text="Σχόλια:"/> 

<s:Label x="10" bottom="10" text="{comments}"/> 
</s:TitleWindow> 
+0

I 동영상의 썸네일을 표시하는 구성 요소는 ... 당신이 클릭 할 때 나는 내가 VideoPopUp.mxml와라는 만든 새로운 윈도우 구성 요소를 호출 생성하는 기능 launchPopUp를 넣어 가지고 있습니다 ... 내가 당신을 설명하게 launchPopUp의 너비와 높이를'win.width = this.width;''win.height = this.height;'로 각각 지정합니다. 이제 VideoPopUp 안에는 높이를 설정하는 비디오 디스플레이가 있습니다. 100 % 및 너비 = 100 %하지만 내가 위의 경우 중 하나만 설정할 때 scaledmode라는 속성을 VideoPlayer 구성 요소에서만 볼 수 있습니다. 무엇을해야합니까? 어떤 생각? – sstauross

+0

width = 100 %로 설정하면되지만 height 속성은 제거하십시오. 그래도 문제가 해결되지 않으면 질문에 VideoPopUp.mxml 코드를 게시 할 수 있습니까? – eterps

+0

위의 팝업 코드를 위에 올려 놓았습니다 ... 하나의 높이 또는 너비를 제거하면 작동하지 않습니다 ... – sstauross

관련 문제