2011-11-23 3 views
0

나는 미디어 서버에 저장된 비디오를 재생하려면 다음 코드를 :크기 조정 비디오 아이

<?xml version="1.0" encoding="utf-8"?> 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" 
     width="592" height="372"> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 
    <fx:Script> 
     <![CDATA[ 
      import mx.events.ResizeEvent; 

      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(); 
       video.attachNetStream(ns); 
       video.smoothing=true; 
       myVid.addChild(video); 
       ns.play("http://localhost:5080/oflaDemo/recordings/firstattempt.flv"); 

      } 



     ]]> 
    </fx:Script> 

    <mx:VideoDisplay id="myVid" bottom="0" width="100%" height="100%"     
    /*??how to make the progressbar work???*/    playheadUpdate="progBar.setProgress(myVid.playheadTime,myVid.totalTime)"/> 

    <s:HGroup right="10" top="7"> 
     <mx:Button id="button4" x="498" y="250" label="Play/Reload" click="fetch_rec();"/> 
     <mx:Button id="button5" x="512" y="279" label="Pause" click="ns.pause()"/> 
    </s:HGroup> 

    <mx:ProgressBar id="progBar" left="10" right="10" bottom="7" height="10" label="" mode="manual"/> 


</s:Group> 

와 나는 비디오가에 따라 만드는 방법 1)을 알고 싶습니다 myVid VideoDisplay의 크기를 조정하면 내부에 작게 표시되지 않으며 2) 스트리밍 된 비디오로 진행률 표시 줄을 만드는 방법 ...

미리 도움을 청하십시오!

답변

1

진행률 표시 줄에 응답 할 수 없습니다. 비디오를 비디오 디스플레이로 스케일링하려면 Transform 및 Matrix를 사용하십시오. VideoDisplay 크기가 변경되면 이전 매트릭스를 새로운 스케일 된 것으로 바꿉니다. 비디오가 대상보다 작 으면 확장해야합니다.

여기에 (나는 등, 창조를 건너) 코드의 조각이다 : 비디오 제작을위한

<!-- language: lang-xml --> 

protected function scaleVideoToDisplay():void { 
    var ratio:Number; 
    if (video == null) { 
     return; 
    }else if (video.width == 0 || video.height == 0) { 
     ratio = 0.0; 
    }else { 
     ratio = Math.min(
       videoDisplay.width/video.width, 
       videoDisplay.height/video.height); 
    } 
    video.transform.matrix = new Matrix(ratio, 0, 0, ratio); 
} 
<s:VideoDisplay width="100%" height="100%" resize="scaleVideoToDisplay()"/> 
<!-- langugae:lang-none --> 

내가 사용

당신은 아마 만든 후 비디오를 확장해야합니다이 외에도
<!-- language: lang-xml --> 

video.transform = new Transform(video); 

.

관련 문제