Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
WorldAgent

MP3Loader: Continue playing sound while loader paused

Recommended Posts

SCENARIO:

I have a 4 minute 5Mb sound track that immediately loads and plays upon visiting the site.

 

In addition to the sound track, there are many other files to load. These other files can load in about 5 seconds. The site does not "begin" until all of the files, including the sound track, have fully loaded. If it weren't for the sound track, the site could "begin" very quickly.

 

 

WHAT I WANT:

I want to be able to load one minute ( or roughly 1Mb ) of the sound track, pause the loading of the sound YET still continue playing the sound, meanwhile letting the other files load. Once the other files have finished loading, I would resume the loading of the soundtrack.

 

 

PROBLEM:

With load progress reporting, I check to see that 20% of the sound has loaded...then do the following:

( FYI: soundTrack is an MP3Loader instance )

 

1. soundTrack.pause(); // This pauses the loading of the sound, yet also results in the sound stopping, though it was already playing via autoPlay:true

2. soundTrack.playSound(); // So here I attempt to play the sound .. yet...

 

I get this error at line 2:

ArgumentError: Error #2068: Invalid sound.

Link to comment
Share on other sites

Sorry, but unfortunately that's simply impossible to do in Flash (it has nothing to do with a limitation in LoaderMax/MP3Loader). You can't really "pause" an individual loader in the true sense - things are either loading or not - no suspended state. When you pause() an individual MP3Loader, it essentially cancels the load which forces it to re-instantiate its internal Sound object, etc. in order to work around garbage collection issues in Flash.

 

My recommendation would be to load your MP3Loader last. That way, you can load all the other assets first and be ready to start quickly. If you need to preload a certain amount of your MP3Loader before starting your app, then put an onProgress listener on the MP3Loader (which loads after all your other stuff) and you can use conditional logic inside that progress handler to kick things off (like if (event.target.progress > 0.2) { startMyApp() }

 

I suppose another option would be to create a version of your MP3 that only has the first 1 minute of your audio and put that into your queue. Then, as soon as your queue finishes loading, you could either load another MP3 that contains the rest of that audio or one that contains the entire version and then as soon as the 1 minute finishes playing, you transition to the other version. It wouldn't be completely seamless, but it probably wouldn't be terrible.

Link to comment
Share on other sites

Thank you for the information.

 

Given that, I will probably go with your either of your alternative suggestions.

 

Cheers.

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.
×