A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: looping a stream sound

  1. #1
    Junior Member
    Join Date
    Jan 2003
    Posts
    14

    looping a stream sound

    hi,
    i have no issues looping an event sound but I can't seem to do it for a stream, my code..

    mySound = new Sound();
    mySound.loadSound("music.mp3",true);
    _root.mySound.start(0,999);
    mySound.setVolume (50)

    or

    mySound = new Sound();
    mySound.loadSound("music.mp3",true);
    _root.mySound.start();
    mySound.setVolume (50);
    mySound.onSoundComplete = function(){
    _root.mySound.stop();
    _root.mySound.start();
    }

    neither works

    when I change the 'true' to 'false' (event sound) it works fine.

    help!!

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Another link you should check:

    http://www.kennybellew.com

    Everything you allways wanted to know about sound, but were afraid to ask!

    BTW, do add (if you did just that!) this to your soundObject definitions (as indicated in the above link!), it will keep you out of further troubles when loading your sound movie in another movie!

    mySound = new Sound(this);
    mySound.loadSound("music.mp3",true);

  3. #3
    Junior Member
    Join Date
    Jan 2003
    Posts
    14
    yes i'm familiar with this tut, I even refered to it yet again to see if i missed something, but can't see anything in particular different to loop a stream.

    the code i'm using is as per tut and a couple of others around, but it doesn't loop.

    i read somewhere that if you use (start) that automatically refers to event sound, could this be the problem?

    thanks.

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    The "loadSound" method of the sound object allows MP3 files to be loaded dynamically. Most of what has already been described about sound objects is true for dynamically loaded sound objects. The notable exceptions involve loading the sound object as streaming versus as an event. If the sound object is loaded as streaming, it begins to play before it has completely downloaded onto the user's computer. If the sound object is loaded as an event, the file must completely load before it can be played.


    Fig. 17: Example of loading an external MP3 file

    The syntax for dynamically loading a sound object with an instance name of "myMusic" is as follows:

    myMusic.loadSound("url", isStreaming)Commonly, the sound object method, "loadSound", is used as follows:

    myMusic.loadSound("sample.mp3", true)
    In the above example, the MP3 file, sample.mp3, is loaded from the same folder that contains the SWF file. It loads into the sound object "myMusic", and it is loading as a streaming sound object. Concerning loading as streaming or as an event, loading as an event is the default. If neither true or false is specified for streaming, the sound object will load as an event.

    To use the loadSound method, the sound object must still be defined. The main difference being that it is not attached to a sound in the library. The following is a common way to define the sound object with the loadSound method:


    myMusic = new Sound(myMusicMc);myMusic.loadSound("sample.mp3");
    In the above example, a new sound object is defined with the instance name of "myMusic", and will load as a child of the movie clip with an instance name of "myMusicMc". This will give you the ability to control its properties independent of movie clip sounds on other timelines.

    In the second line, the external file "sample.mp3" is instructed to load into the sound object "myMusic". It will load as an event, versus streaming, as the Boolean value of true or false is not specified. Therefore, the default status (event) will be used.

    All of the controls for sound objects described thus far work for dynamically-loaded streaming MP3's, with the exception of starting the MP3 with the mySoundObject.start() method. Streaming MP3's start as soon as there is enough data to play the sound; therefore, the loadSound call to the sound object is the start command. However, you should be able to stop the streaming sound and restart it with the mySoundObject.start() call. Currently, this option is only partially available due to a bug in the Flash Player.

    With the r40 release of version 6 Flash player, this issue was addressed. If you are going to use the mySoundObject.start() method to restart the streaming sound object, you must make sure that the user has the latest Flash player. The Flash Deployment Kit from Macromedia provides instructions on making sure the latest plug-in is installed on the user's computer.


    Test your Flash player for this issue with the Flash example in Fig. 17b.


    Going to bed!

  5. #5
    Junior Member
    Join Date
    Jul 2002
    Posts
    9
    I have found a way that seems to work for this very thing, code as follows

    mySound = new Sound
    mySound.loadSound("music.mp3", true)
    mySound.onSoundComplete(
    start(0,999)
    )
    mySound.setVolume(50)
    Do you grow an orange tree?

  6. #6
    Junior Member
    Join Date
    Jan 2003
    Posts
    14
    thanks firstade,

    no luck unfortunately, check it out for y self..

    i can't believe this thing won't loop.
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Jan 2003
    Posts
    14
    i need this sorted quick.

  8. #8
    Junior Member
    Join Date
    Jul 2002
    Posts
    9
    sorry the code should be:

    on (release) {
    stopAllSounds();
    mySound = new Sound();
    mySound.loadSound("sounds/dance_02.mp3", true);
    mySound.onSoundComplete = function() {
    mySound.start(0, 500);
    };
    mySound.setVolume(25);
    }

    hope this helps
    Do you grow an orange tree?

  9. #9
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    That second script works fine. Just hit the green button.
    That's the only button I've cared about!

    http://members.lamicro.com/~FGill/untitled-11111.swf

  10. #10
    Junior Member
    Join Date
    Jan 2003
    Posts
    14
    hey guys, no luck again, i'm sure i'm not doing anything wrong,
    check the new file wit new code.

    old.. I could't open ure attachment, got to a quicktime logo and nothing more.
    Attached Files Attached Files

  11. #11
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    It wasn't an attachment? It's a link!

    http://members.lamicro.com/~FGill/stream.swf

  12. #12
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Here's your last try...

    http://members.lamicro.com/~FGill/untitled5.swf

    Hope you're not trying to make this loop in the application itself, without having downloaded the lastest test player itself, and I'm not talking about the browser plug-in.

    Have you tested your file on-line? Have you uploaded your mp3 also?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center