Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

createSound, on complete jump to next sound

I'm creating a music player. But since all the audio files are running within the application I can't use the createAudioPlayer function.

So what i've done is create a variable which holds the player.. BUT when the sound is finished i need to assign a new song.. Thus create a new Sound instance.. so, normally, in javascript when you overwrite the player var it should be empty.. but, it seems like Titanium just creates a new instance with the same name (?).


var _num = 1;
var _max = 3;

var player = null;

function playSound(num) {
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'sound/' + num + '.mp3');

_num = num;

player = Ti.Media.createSound({
url: file.nativePath,
preload: true

player.addEventListener('complete', function() {
if(_num < _max) {
} else {
_num = 1;


I do it like this, since player.setUrl() or player.setFile() don't exists and i can't figure out another way to use it..

— asked August 1st 2010 by J T
  • mobile
  • mp3
  • music
  • sound
  • Nevermind, fixed it myself! :-)

    — commented August 1st 2010 by J T
  • how did you that? i can't make jump the next sound :( can you share your code ?

    — commented August 10th 2012 by Graham Jeffrey
  • I'd like to see that too

    — commented November 8th 2012 by Julien Gattegno

1 Answer

  • Please post an answer with the way you used to do it so that we see the solution.


    — answered November 18th 2012 by Michael Massalas
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.