0

現在、リストとして持つ複数のソースからストリーミングできるアプリを作成しようとしています。ユーザーがリストの選択肢をクリックしてから、「再生」ボタンをクリックして、ストリームを開始してもらいたいと思います。私のコードは現在動作していますが、再生したいストリームを明示的に述べています.req new URLリクエストにURLを動的に渡す方法が見つかりません. コードは以下です>

<?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="Stream Southeast Ak Stations" destructionPolicy="never">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>


<fx:Script
    >
    <![CDATA[
        private var req:URLRequest;
        private var context:SoundLoaderContext = new SoundLoaderContext(8000);
        private var s:Sound;
        private var channel:SoundChannel = new SoundChannel();
        private var playingBln = new Boolean


        private function playAudio():void
        {
            if (playingBln == true)
            {playingBln = false;
                channel.stop();
                s.close()
                req = new URLRequest('http://stream.ktoo.org:8000/ktoo');
                s = new Sound(req, context);
                channel = s.play();
                playingBln = true

            }
            else{
                req = new URLRequest('http://stream.ktoo.org:8000/ktoo');
                s = new Sound(req, context);
                channel = s.play();
                playingBln = true
            }
        }
        private function stopAudio():void
        {
            if (playingBln == true)
                channel.stop();
            s.close()
            playingBln = false;
        }           
    ]]>
</fx:Script>



<s:Label text="Choose a Station"/>
<s:List id="stationList" 
        width="100%" 
        height="100%"
        labelField="name"
        >

<s:ArrayCollection>
<fx:Object name="KTOO" location="Juneau" streamURL="http://stream.ktoo.org:800/ktoo"/>
<fx:Object name="KXLL" location="Juneau" streamURL="http://stream.ktoo.org:800/kxll"/>
<fx:Object name="KRNN" location="Juneau" streamURL="http://stream.ktoo.org:800/krnn"/>
<fx:Object name="KFSK" location="Petersburg" streamURL="null"/>
<fx:Object name="KSTK" location="Wrangell" streamURL="null"/>
<fx:Object name="KCAW" location="Sitka" streamURL="null"/>
<fx:Object name="KRBD" location="Ketchikan" streamURL="null"/>
</s:ArrayCollection>

</s:List>
<s:Button x="10" y="309" width="100" height="42" label="Play" click="playAudio()"/>
<s:Button x="139" y="310" width="99" label="Stop" click="stopAudio()"/>



</s:View>
4

1 に答える 1