Audio.play() OnComplete function never gets called

Hi

I’m updating my app for the first time in 3 years. However, something has stopped working that was working before. My app is about music theory and one thing it does is play scales up and down. There’s a play button that the user taps, and then the scale plays. While it plays, the listeners on the play button and advance-to-next-screen button are removed, but once the scale is done playing the listeners is supposed to be added back. This still works properly on my 3 year old version on the app store. However, using the latest Corona simulator and a new Macbook running OS 14.2, the audio.play function’s onComplete is never called (without my making any code changes) which means the listener doesn’t get added back to the buttons once the scale is over. This is the listener function for my play button. Any help appreciated. Thanks in advance.


hearButtonListener = function(event)

if ( event.phase == "began" ) then  
     	display.getCurrentStage():setFocus(event.target)

   	elseif  ( event.phase == "ended" ) then	 

		display.getCurrentStage():setFocus(nil)
	
	if (scaleData.areWeEvaluating == true) then	
		scaleData.nextButtonBG:removeEventListener("touch",nextButtonListener)		
		scaleData.nextButtonBG.alpha = 0.5
	end
	
	commonData.hearButton:removeEventListener("touch",hearButtonListener)
	commonData.hearButton.alpha = 0.5
			
	local up = true
	local i = 1
	local channelCounter = 1
	local iterations = 0
	
	local function  areWeDone(event) -- HAS THE SCALE HAS FINISHED PLAYING?

		if event.channel == iterations then -- put back the next button listener
			commonData.hearButton:addEventListener("touch",hearButtonListener)
			commonData.hearButton.alpha = 1
			if (scaleData.areWeEvaluating == true) then	
			scaleData.nextButtonBG:addEventListener("touch",nextButtonListener)									
			scaleData.nextButtonBG.alpha = 1
			end
		end
	
	end -- end of inner function areWeDone

	local playSounds = function(event)
	
		if up == true then
			audio.play(scaleData.soundArray[i],{channel = channelCounter, onComplete = areWeDone})
			i = i + 1
			if i == #scaleData.soundArray then up = false end
	
		elseif up == false then
			audio.play(scaleData.soundArray[i],{channel = channelCounter,
			onComplete = areWeDone}  )
			i = i - 1
		end	

		channelCounter = channelCounter + 1

	end
	
	if scaleData.scaleArray[scaleData.scaleNumber][5] == "melodic minor" then
		iterations = 15
	else iterations = (#scaleData.soundArray * 2) - 1
	end

	scaleData.theTimer = timer.performWithDelay(250,playSounds,iterations)
	scaleData.timerTable[scaleData.timerIndex] = scaleData.theTimer
	scaleData.timerIndex = scaleData.timerIndex + 1
	end
end

This was a goof of mine, while fixing (I hope) the crashes common to this feature. I expect the proper fix will be integrated soon, but in the meantime you can roll back to 3699 or so. (Also, for Android specifically I posted a binary in Discord in the #help-and-support channel, if you’re interested.)

Thanks. I got as far as here: Release Solar2D 2023.3699 · coronalabs/corona · GitHub but I’m not sure how to download this. Cheers.

Hello d2gp,

You should be able to see “Assets (9)” at the bottom of the page on the URL as indicated by you. It lists 9 distribution packages. For example, for the windows binary, it would be,

Solar2D-Windows-2023.3699.msi

If you cannot see the list of 9 packages, click on “Assets” to drop down the list. Hope this helps.

Got it, thanks.