Jump to content
GreenSock

ollieolarte

MP3Loader, after SOUND_COMPLETE how to playSound() again??

Recommended Posts

Ye, people, Dis a Great API to play with, just haff som choble!

 

1-I want to load an MP3

2-After Loaded I wanna play it with looping turned off (because i couldnt make it fire the SOUND_COMPLETE event if repeat: -1)

3-I want to hear when the loop ends and fire an event to trace a message (to make som more stuff later)

4-if the user has not made any choice, the loop starts again and repeat steps 2, 3, 4 until something happen

 

BUT I CANTGET THE SOUND TO playSound() again!!!!

 

so heres my code:

 

(dis is just som draft of what i want!)

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;

var piano:MP3Loader=new MP3Loader("piano_loop.mp3",{name:"piano",autoPlay:false,repeat:0});
piano.load();
// i will add som line here later, so the sound only plays when finished loading... dis is just a desktop test
piano.playSound();	

//up to dis point it sounds normally

piano.addEventListener(MP3Loader.SOUND_COMPLETE,pianoCompleteHandler);
function pianoCompleteHandler(event:LoaderEvent):void
{
// YES!, the event fires as expected
// by the way the event does not fire if ----> repeat:-1

trace("piano complete loop!")

// WHY doesnt it play again?? with dis line????
piano.playSound();	

}

 

Where am I wrong... or maybe is there som any other way of doing it?

 

any help is greatly appreciated

 

blessed!

Link to comment
Share on other sites

ohhh i just relized how to do dat!!!

 

i didnt have to playSound();

 

i had to gotoSoundTime(0,false)!!!

 

becase the play time ended and i had to reset the time

 

 

THANKSSSS man!!!

i love this entire API everything is just so perfect!!! :D

 

i will donate soon :D :D

Link to comment
Share on other sites

thank you for taking the time to post your solution. it could be very helpful to people searching in the future.

 

Glad you figured it out. have fun with LoaderMax

Link to comment
Share on other sites

Man but I stll have a little issue, when the loop ends, re initializes it has som delay, any idea of how to avoid that delay and hear the loops continually?

Link to comment
Share on other sites

You can set the number of times to repeat the sound using the "repeat" special property in the vars parameter. For example, to repeat the MP3 twice, do this:

 

var audio:MP3Loader = new MP3Loader("audio.mp3", {autoPlay:true, repeat:2});
audio.load();

 

Otherwise, to do it manually, you could use the rawContent (which is the Sound object) and define the value via the play() method, like:

 

myMP3Loader.rawContent.play(0, 2);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×