2013-08-06 71 views
0

我想能夠PAN通過flv文件的立體聲通道。 表面上,這樣我可以在播放flv時播放2種語言之一(右聲道或左聲道)。 我已經用混音器「演奏」過,並且無法使用此功能與flv一起工作。如何PAN(改變聲音平衡)flv文件的立體聲通道

我可以在videoPlayer上使用soundMixer嗎?如果是的話,任何人都可以糾正我的(下面)代碼嗎?

TIA, Phil。

<?xml version="1.0" encoding="utf-8"?> 
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"> 

    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <fx:Script> 
     <![CDATA[ 

      protected function myVideo():void 
      {    
       var soundMixer:SoundTransform = new SoundTransform(); 
       soundMixer.pan = 1; 
       myVid.soundTransform = soundMixer; 

       myVid.play(); 
      } 

     ]]> 
    </fx:Script> 

    <s:VGroup width="100%" height="100%"> 
     <s:Button id="playVideo" label="Video" click="myVideo()"/> 

     <s:VideoPlayer id="myVid" 
         source="assets/caroLang.flv" 
         volume="1.0" 
         width="50%" height="50%" 
         autoPlay="false" 
         autoDisplayFirstFrame="true" 
         scaleMode="letterbox" 
         /> 
    </s:VGroup> 
</s:View> 
+0

看看'soundTransform'。 – putvande

回答

0

決定改變大頭貼和使用多個mp3文件(每種語言一個)與視頻播放,它沒有音頻。

我正在測試selectLang變量並根據值播放不同的mp3文件。

通過點擊視頻按鈕啓動該過程,他們可以停止,暫停或使用清理欄將視頻和mp3移動到適當的同步位置。

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

<fx:Script> 
    <![CDATA[ 
     import mx.core.SoundAsset; 
     import mx.events.FlexEvent; 

     import spark.components.mediaClasses.ScrubBar; 

     import org.osmf.events.MediaPlayerStateChangeEvent; 
     import org.osmf.events.TimeEvent; 
     import org.osmf.traits.PlayState; 

     private var seletedLang:String = "EN"; 

     public var loadedFile:File; 
     public var channel:SoundChannel; 
     public var songEN:SoundAsset; 
     public var songPT:SoundAsset;   
     private var currentVidTime:Number = 0; 


     protected functio view1_creationCompleteHandler(event:FlexEvent):void 
     { 
      songEN = new SoundAsset(); 
      songEN.load(new URLRequest("assets/caro.mp3")); 

      songPT = new SoundAsset(); 
      songPT.load(new URLRequest("assets/caro.mp3")); 

      myVid.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, scrubBarChange); 
     } 

     protected function scrubBarChange(event:TimeEvent):void 
     { 
      currentVidTime = event.time; 
     } 

     protected function myVideo():void 
     {         
      if(seletedLang == "EN") 
      { 
       channel = songEN.play(currentVidTime*1000); 
      } 
      else 
      { 
       channel = songPT.play(currentVidTime*1000); 
      } 

      myVid.play(); 

     } 

     protected function myVid_mediaPlayerStateChangeHandler(event:MediaPlayerStateChangeEvent):void 
     { 
      trace(event.state); 

      if(event.state == "playing") 
      { 
       if(seletedLang == "EN") 
       { 
        trace("**** " + currentVidTime); 
        if (channel != null) channel = songEN.play(currentVidTime*1000); 
       } 
       else if (seletedLang == "PT") 
       { 
        if (channel != null) channel = songPT.play(currentVidTime*1000); 
       } 
      } 
      else if(event.state == "paused") 
      { 

       if (channel != null) SoundMixer.stopAll(); 
      } 
     } 


    ]]> 
</fx:Script> 

<s:VGroup width="100%" height="100%"> 
    <s:Button id="playVideo" label="Video" click="myVideo()"/> 

    <s:VideoPlayer id="myVid" 
        source="assets/caroMute.flv" 
        volume="0.0" 
        width="50%" height="50%" 
        autoPlay="false" 
        autoDisplayFirstFrame="true" 
        scaleMode="letterbox" 
        mediaPlayerStateChange="myVid_mediaPlayerStateChangeHandler(event)" 
        /> 
</s:VGroup> 
</s:View> 
相關問題