Jump to content
Search Community

MP3Loader repeat problem

mustaffa test
Moderator Tag

Recommended Posts

Hi there,

I have a problem with playing mp3. I need to play it forever and used repeat:-1. It works well unless it is paused. When the sound is unpaused it continues as normal but when it finishes it does not start from the beginning, starts from where it was paused. It looks strange and I could not figure out why.

 

Here is my code:

 

import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
var sound:MP3Loader = new MP3Loader("music.mp3", {name:"audio", autoPlay:true, repeat:-1, estimatedBytes:400000});
sound.load();

// function to toggle soundpaused state
function btn_SesAcik_mc_MouseClickHandler(event:MouseEvent):void
{
sound.soundPaused  = !sound.soundPaused;
}

 

 

I appreciate if you could help.

 

cheers

mustafa.

Link to comment
Share on other sites

yes, that does appear strange.

 

try using an Event.SOUND_COMPELTE eventListenre like so:

 

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

var sound:MP3Loader = new MP3Loader("music.mp3", {name:"audio", autoPlay:true, estimatedBytes:400000});
sound.load();

sound.addEventListener(Event.SOUND_COMPLETE, playAgain);

function playAgain(e:Event):void{
sound.gotoSoundTime(0,true);
}

stage.addEventListener(MouseEvent.CLICK, toggles);

// function to toggle soundpaused state
function toggles(event:MouseEvent):void
{
  sound.soundPaused  = !sound.soundPaused;
}

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.
×
×
  • Create New...