Jump to content
GreenSock

Gerald Yeo

MP3Loader sound doesn't repeat indefinitely (-1) after soundtransformed

Recommended Posts

Hi,

 

I can't seem to find any mention of this in the forums, so I'm asking this:

 

I've loaded an mp3 file and initiated it using the XMLLoader.

 

<LoaderMax name="MediaPreloader" load="false">
<MP3Loader url="mp3s/tea.mp3" name="audio-tea" autoPlay="false"
repeat="-1" />
</LoaderMax>

 

This LoaderMax instance's load is manually started. Everything loaded fine and the sound is played and panned to the right, as it should be.

 

TweenPlugin.activate([soundTransformPlugin]);
var _fgs:MP3Loader = LoaderMax.getLoader('audio-tea');
_fgs.volume = 0;
_fgs.playSound();
TweenMax.to(_fgs.channel, 1, {soundTransform:{volume:1, pan:1}});

 

Now, the issue I'm facing is that the sound doesn't repeat indefinitely, even when I configured it to repeat -1 in the xml.

 

Anyone facing this issue?

Link to comment
Share on other sites

Hi Gerald,

 

Welcome to the GreenSock forums. Sorry to hear you are having problems.

 

Can you please do a quick test for me?

 

Configure the initial volume to something greater than 0 like:

_fgs.volume = .1;

 

It appears to me that the sound IS repeating but the volume is somehow being reset to 0 after the soundTransform tween runs.

 

If you can confirm that you can hear the sound repeating at a low volume that will be great.

 

I prepared a set of files that attempts to replicate what you are working with as best as I can so that our Lead Developer can easily address the issue for you.

 

It looks like this:

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.plugins.*;
TweenPlugin.activate([soundTransformPlugin]);
LoaderMax.activate([MP3Loader]);

var _fgs:MP3Loader;
var xml:XMLLoader = new XMLLoader("sound.xml", {onComplete:xmlComplete});

function xmlComplete(e:LoaderEvent):void{
_fgs = LoaderMax.getLoader("audio-tea");
_fgs.addEventListener(LoaderEvent.COMPLETE, mp3Complete);
_fgs.load();
}

function mp3Complete(e:LoaderEvent):void{
trace("mp3 loaded");
_fgs.volume = 0.1; // change this to 0 and sound will repeat but not be audible
_fgs.playSound();
TweenMax.to(_fgs.channel, .5, {soundTransform:{volume:1, pan:1}});
}

xml.load(); 

 

Those files are attached below incase you want to test or compare them to what you are doing. On my end I can confirm that yes the sound is inaudible on repeat when the initial volume is 0.

 

I also created a version that removes XMLLoader from the mix and the same issue was present.

 

Thank you for taking the time to post here and for explaining the issue so clearly. We will do our best to get back to you as soon as possible. Please understand that it is a weekend. We appreciate your patience.

 

-Carl

soundRepeat_CS5.zip

Link to comment
Share on other sites

I see the problem - it has to do with the fact that you're directly tweening the SoundTransform of the channel instead of the volume of the MP3Loader instance. It actually is related to the fact that in Flash, an object's SoundTransform isn't consistent, so (channel.soundTransfrom == channel.soundTransform) will return false! So if you do channel.soundTransform.volume = 0.5 and then trace() the value, it won't be set to 0.5! Anyway, I injected a workaround that should solve the problem for you - can you test the attached file and let me know if it works well for you?

MP3Loader.zip

  • Like 1
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.
×