Search code examples
titaniumappceleratoraudio

Playing different Sound files in Appcelerator Titanium makes the audio got noise


I have created an app using appcelerator for Iphone , which buy click on buttons it will play a relative sound , here is the code, but the problem is when i play the audio many times and play different audios using this function the sound starts to lag and have noise inside, can anybody help me with it , Thanks.

    var soundplaying = 0;
    var sound;

    function playaudio(url) {
        if (soundplaying == 0) {
            sound = Ti.Media.createSound({});
            sound.setUrl('../assets/audio/' + url);

            sound.addEventListener('complete', function() {
                sound.release();
                soundplaying = 0;
            });
            sound.play();
            soundplaying = 1;
        }
    }

(i have tried to release the sound object after each time but still no use, I tried to createSound only once but seems the titanium dose not support changing url for Media.Sound) dynamically.


Solution

  • I could have solve this issue temporary , by changing the audio files format to .m4a (aac). i was using mp3 earlier.