Playing sound files repeatedly after each others by, for example pressing a button is very buggy in 1.7.2.
It works perfect in 1.6.2 so something must have happened. There are some forum threads about it also.
I've made a sample application that has a button which will play a sound if clicked (attaching sample soundfile: cat.wav). Note that the format doesn't matter at all.
When running the app, note that the sound won't play all of the times the button is pressed. You can also see that the complete event is not run on these occasions. This is in 1.7.2, switching to 1.6.2 the sound plays every time 100%. I've tried reusing the player, not releasing it and so on, no luck.
var playCounter = 0;
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',
orientationModes:[Ti.UI.LANDSCAPE_RIGHT]
});
var button = Ti.UI.createButton({
title:'click'
});
button.addEventListener('click', Playsound);
win.add(button);
win.open();
function Playsound(){
playCounter++;
Ti.API.info("Playing sound, nr: " + playCounter);
var player =Ti.Media.createSound({
url: "cat.mp3"
});
player.addEventListener('complete', function(e) {
player.release();
player = null;
Ti.API.info("Sound played correctly");
});
player.play();
}
Andreas Which release of the 1.7.2 SDK did you test? It's worth including date and hash that is output to log when the app is launched to make this obvious. However, thanks for the great ticket - moving to the main project.
The log tells me: 1.7.2.97c3689 The date would be 5 minutes ago I suppose since I tested it again to be sure it still doesn't work :) The hash: (I'm not sure this is what you are asking for) ...... /iPhone Simulator/4.2/Applications/BFC0BAF2-00E2-4FCB-840C-24B25135645A/ .......
Fixed by a previous checkin.
Bug fixed. Verified on: SDK: 1.8.0.1.v20111208104316 Studio: 1.0.7.201112080131 OS: OS X Lion Devices Tested: iPhone Simulator 5.0, iPod 4.3.3, iPhone 5.0.1
Open to add label