#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    660
    Rep Power
    31

    Is this streaming the audio or loading the audio into the swf first, then playing it?


    I think it is loading the whole audio first into the swf, but I would like to get confirmation from someone more knowledgible.

    Code:
    var sc:SoundChannel = new SoundChannel();
    var s:Sound = new Sound();
    var soundReq:URLRequest = new URLRequest("http://sample.com/audio.mp3");
    s.load(soundReq);
    
    function btnClick(e:MouseEvent):void
    {
    		sc = s.play();
    }
    I want it to stream the audio when the button is clicked only so that 100 of these swf will not slow down a whole webpage from loading.

    I am thinking this would be the solution, is this right? Also is there a better way?

    Code:
    var sc:SoundChannel = new SoundChannel();
    var s:Sound = new Sound();
    var soundReq:URLRequest = new URLRequest("http://sample.com/audio.mp3");
    
    function btnClick(e:MouseEvent):void
    {
    s.load(soundReq);
    sc = s.play();
    }
    I only start getting concerned when I noticed that on FF and Chrome, the page loads really quick but when I open the page in IE, it takes a very long time for the page to appear. Maybe its IE?
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,675
    Rep Power
    3164
    Yes, if you do load at the start then it will start loading the file straight away, trying to reach the buffer limit. You are better doing it the second way and only doing load once the button has been clicked.

    If you do stop on the sound channel then the file will continue downloading in the background. If you want to stop that then do close on the Sound instance directly and the streaming will cease immediately. Note that once you've done close you cannot re-use that same Sound instance and will have to create a new one.
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    660
    Rep Power
    31
    Tann,

    Is there any way of stopping and continuing streaming to create a sort of pause and play feature. So that it can continue streaming from where it stopped?
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,675
    Rep Power
    3164
    Well the sound objects play method takes a startTime as the first parameter (see here). So when they click stop you could store the SoundChannels position and then close the Sound instance. Then when they click play again, create a new Sound instance and tell it to play from the position you stored. Not sure how instant that will be, don't remember ever doing this.
    Quis custodiet ipsos custodes?

IMN logo majestic logo threadwatch logo seochat tools logo