Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5298] iOS: Can't play sound files repeatedly in 1.7.2

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T14:55:56.000+0000
Affected Version/sn/a
Fix Version/sSprint 2011-46, Release 1.8.0.1
ComponentsiOS
Labelsmodule_media, qe-testadded
ReporterAndreas Oberg
AssigneeReggie Seagraves
Created2011-08-11T16:24:17.000+0000
Updated2012-01-04T14:55:56.000+0000

Description

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();
}

Attachments

FileDateSize
cat.mp32011-08-11T16:24:17.000+000023822

Comments

  1. Paul Dowsett 2011-09-17

    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.
  2. Andreas Oberg 2011-09-17

    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/ .......
  3. Reggie Seagraves 2011-11-15

    Fixed by a previous checkin.
  4. Dustin Hyde 2011-12-08

    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
  5. Natalie Huynh 2012-01-04

    Open to add label

JSON Source