Skip to content

How to check that sound is already load? #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
katopz opened this issue Jul 23, 2013 · 5 comments
Open

How to check that sound is already load? #11

katopz opened this issue Jul 23, 2013 · 5 comments

Comments

@katopz
Copy link

katopz commented Jul 23, 2013

Hi, noobs here!

question is... How to check that sound is already load?
so i can just play if sound already load...
far as i try is

var si:SoundInstance = SoundAS.getSound("somesound");

but at present it will throw error if it not exist, i did expected null for first load then call SoundAS.loadSound if si is null e.g.

if(!si)
    SoundAS.loadSound("somesound.mp3", "somesound");

and if i load sound via SoundAS.loadSound again without check for existing
SoundAS.loadCompleted is seem to be never fire for second load same url and type.

btw, i don't think it's a good idea to try catch there. "null for non exist SoundAS.getSound" should be better there.

Thanks

@lynxerzhang
Copy link

I have a same problem.

public function getSound(type:String, forceNew:Boolean = false):SoundInstance

if specfied type is not found, it will throw new error, and this error not catch in SoundManager.

so is should possible add catch in that "try...finally" code block ? or if not found specfied sound, do not fire a error, just trace a message?

or maybe add a new method containSound?

@MSGhero
Copy link

MSGhero commented Jul 4, 2014

I changed it locally so that getSound returns null instead of throwing an error. Though a containsSound would be good.

@Adolio
Copy link
Contributor

Adolio commented Jul 4, 2014

I did the same on my side.

@iiilx
Copy link

iiilx commented Oct 31, 2014

yes please add support for containsSound!

@Adol
Copy link

Adol commented Dec 21, 2016

SoundAS.getSound('XXX').sound.addEventListener(Event.COMPLETE,COMPLETE);
SoundAS.getSound('XXX').sound.addEventListener(IOErrorEvent.IO_ERROR,IO_ERROR);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants