I'm writing an app that allows the user to play various sound files.
Some of these files are mp3, but some may also be ogg, wma, etc. The selection is out of my control, so I need the sound API to tell me if it can't play something.
To test, I loaded some test files into a sound object like so:
var urlRequest:URLRequest = new URLRequest("http://support.microsoft.com/support/MediaPlayer/wmptest/samples/new/mediaexample.wma");
var sound:Sound = new Sound();
var soundChannel:SoundChannel = sound.play();
Even though Flex doesn't play wma's there is no error information or null objects anywhere. Everthings seems to be fine to flex, I can even register for progress events and see the wma being loaded.
Just to see how far this goes, I loaded a gif instead of an audio file and the same thing happened. Progress went fine with no errors of any kind even though I registered for every listed event. As expected though, no sound played from the gif file.
What is the recommended way for checking if a file is not playable?
I don't see any obvious error event to tell you if it's not an MP3 file. Can you just check the file extension before permitting the load()?
I'm looking more for an "is it playable" value (since it might be an FLA or FLV as well).
Even a meaningful length value would work (for some reason duration is set to a value even when loading a gif file - not sure what it means for a GIF to have a length of 96 milliseconds).
For now I'll have to filter on extension as you mentioned.