I’m loading a (user-generated) MP3 file in my project to be played:
cc.assetManager.loadRemote(mp3_url, function (err, audioClip) {
cc.audioEngine.playMusic(audioClip, false);
});
However, I can’t actually know if that is a valid MP3. Is there a way to check if it is a valid MP3?
Thanks!
You mean that you don’t know if the file can be play properly?
Jgod
#4
Probably better to check it on your own server.
Is there a way to check if the loaded asset is an MP3 at all?
cc.assetManager.loadRemote(mp3_url, function (err, audioClip) {
cc.audioEngine.playMusic(audioClip, false);
});
or can I prevent my app from crashing when
cc.audioEngine.playMusic(audioClip, false);
is called on a non-MP3 (or corruptly downloaded) file? Something like try… catch?
(Is there a way to do a
try
...
catch
style handling of exceptions when AudioPlayer stumbles across an unplayable file?)
Which platform are you publishing ?
Will this enable me to have
try
catch
-style handling of unplayable MP3s?
PP_Pro
#10
Sorry, for now there is no way to verify audio file
as Jgod said, it’s better to check it on your own server.
1 Like
I see!
Is there a way to do a
try
catch
construction to catch the exception if an error during playback happens?
Thank you!