3 Replies Latest reply on Mar 15, 2014 1:47 PM by Dan Gz

    Flex Stream error

    Dan Gz

      Hello, I've been killing my head trying to figure this out, i've tried in many different ways, but i can't get to load a sound I need to make a Radio Player, i have te http source but it wasn't working so I first tried with the most basic which is loading a sound from my project, here's my code:

       

      <?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:Script>

              <![CDATA[

                  import adobe.utils.CustomActions;

                  import air.net.URLMonitor;

                  import flash.media.Sound;

                  import flash.media.ID3Info;

                  import flash.net.URLRequest;

       

                  var sound:Sound = new Sound(new URLRequest("Remains.mp3")); //this is in the views folder, i tried moving it to another folder and changing its respective path but nothing.

                  var my_channel:SoundChannel;

                  var pausePos:int = 0;       

       

                  protected function play(event:MouseEvent):void

                  {

                      my_channel= sound.play();               

                  }

       

              ]]>

          </fx:Script>

       

          <s:Button click="play(event)">

       

          </s:Button>

      </s:View>

      I keep getting this:

      Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
      Also I tried doing it as a Flex Web application but it isn't working either, i don't know if it has to do with executing it via localhost or something, please help me, I'm new to this.

      I could get around that error by doing this:

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                     xmlns:s="library://ns.adobe.com/flex/spark"

                     xmlns:mx="library://ns.adobe.com/flex/mx"  minWidth="955" minHeight="600">

          <fx:Script>

              <![CDATA[

                 

                  import flash.media.*;

                 

                  [Embed(source="music/Remains.mp3")]

                  [Bindable]

                  public var sndCls:Class;

                 

                  public var snd:Sound = new sndCls() as Sound;

                  public var sndChannel:SoundChannel;

                 

                  public function playSound():void {

                      sndChannel=snd.play();

                  }  

                 

                  public function stopSound():void {

                      sndChannel.stop();

                  }  

              ]]>

          </fx:Script>

         

          <s:HGroup>

              <s:Button label="play" click="playSound();"/>

              <s:Button label="stop" click="stopSound();"/>

          </s:HGroup>

      </s:Application>

      however the sound is never played.

        • 1. Re: Flex Stream error
          Flex harUI Adobe Employee

          You should add an event listener for IOErrorEvent.IO_ERROR.  The event will tell you more about what is going wrong.  You'll need this in production in case something really goes wrong.

           

          The URLRequest is set up to find the mp3 in the same folder as the SWF since no paths are specified.  The error you are getting might mean that the mp3 file is not there.

          • 2. Re: Flex Stream error
            Dan Gz Level 1

            it is there, i made sure, actually if i move it to somewhere else and try to run the application, a warning shows up sayimg that the file couldn't be found. let me try that

            • 3. Re: Flex Stream error
              Dan Gz Level 1

              I solved it, turns out that my computer was infected with something that was redirecting everything, from files to programs. Thanks anyway