.play() crashes iPad

You must Login before you can answer or comment on any questions.

If I create a sound object and then try to play it, app immediately crashes. I need to set it's url in another eventListener but even if I specify a url directly it still crashes.

If I comment out the audio.play() line, no crash;

Ideas?? Pulling my hair out!! Thx!

// Play selected audio file
var audio = Ti.Media.createSound();
audio.url = 'files/audio/filename.mp3';
audio.preload = true;
 
var play = Titanium.UI.createButton({
    title:'Play',
    height:40,
    width:125,
    left:10,
    top:10
});
 
play.addEventListener('click', function()
{
    audio.play();
    Ti.API.info(audio.url); // can see it here
});

— asked 3 years ago by Kelly Redd
1 Comment
  • I have something similar, but I can get it to play 4 or 5 times before the crash. Oddly, I have another app on the store without any audio crash problems whatsoever (though now that I think about it, I built that app with a Ti version somewhere in between 1.3 and 1.4)

    — commented 3 years ago by karlo kilayko

1 Answer

How long is the sound? Have you tried it with createAudioPlayer() instead? I recall that createSound() is intended for short sounds (like system sounds) while createAudioPlayer() is intended for longer sounds (like music).

— answered 3 years ago by Rafael Hernandez
answer permalink
1 Comment
  • Thanks Rafael, i've gotten past that now. I think it was a misuse of createSound() on my end.

    I'm still using createSound() but I figured out that I need to switch b/n specifying a url and sound based on where the source was coming from - either having just been recorded and not saved(sound) or a file that has been saved(url).

    createSound() seems to be working fine but your answer makes me wonder if createAudioPlayer() would be more appropriate for the url source.

    — commented 3 years ago by Kelly Redd

Your Answer

Think you can help? Login to answer this question!