0

我希望能够平移 flv 文件的立体声通道。表面上这样我可以在播放 flv 时播放 2 种语言中的一种(右声道或左声道)。我已经“玩过”混音器,但无法让它与 flv 一起使用。

我可以将 soundMixer 与 videoPlayer 一起使用吗?如果可以,有人可以更正我的(以下)代码吗?

TIA,菲尔。

<?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>
4

1 回答 1

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>
于 2013-08-07T13:53:13.547 回答