Hi,
I have a project to learn English and I’m problems with audio.
In quiz scene, I like play an audio in order to users can listen a phrase in every quiz. This works fine until the first 85 reproductions, but the next audio reproduction doesn’t work, I haven’t any error on console, but Corona don’t execute audio.play because don’t enter into complete listener.
I tried isolate this part of code but with the same results.
This is the code:
local composer = require( "composer" ) local unidad = 5 local test = 1 local contador = 1 local continuar = true local fallo = false local totalFallos = 0 local tm local scene = composer.newScene() function scene:create( event ) local sceneGroup = self.view end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then local lblNumQuiz = display.newText( sceneGroup, "Unidad: " .. unidad .. " - Test: " .. test, 160, 80 , native.systemFont , 18 ) local lblactual = display.newText( sceneGroup, "contador actual: " .. contador, 160, 200 , native.systemFont , 18 ) local function esperar( ) lblNumQuiz.text = "Unidad: " .. unidad .. " - Test: " .. test lblactual.text = "contador actual: " .. contador local function networkListener( event ) if ( event.isError ) then print( "Network error - download failed: ", event.response ) elseif ( event.phase == "began" ) then print( "Progress Phase: began" ) elseif ( event.phase == "ended" ) then local function lstnFinalizado (event) if event.completed then print("Se ha reproducido correctamente el audio") isReproducido = false audio.dispose( ficheroAudio ) ficheroAudio = nil audioChannel = nil else print("No se ha completado el audio") isReproducido = false end end print( "Archivo descargado" ) local ficheroAudio = audio.loadStream("audio" .. contador .. ".mp3", system.DocumentsDirectory) if ficheroAudio == nil then print("No se ha podido descargar el fichero") audio.play( koSound, { channel=1 } ) fallo = true totalFallos = totalFallos + 1 else local audioChannel = audio.play(ficheroAudio ,{ channel=3, onComplete=lstnFinalizado }) totalFallos = 0 end if fallo then test = 1 unidad = unidad + 1 fallo = false if totalFallos == 2 then local lblfinal = display.newText( sceneGroup, "contador final: " .. contador, 160, 400 , native.systemFont , 18 ) timer.cancel( tm ) end else test = test + 1 end contador = contador + 1 end end local params = {} params.progress = true network.download( "https://SERVERURL/audio/" .. unidad .. "\_" .. test .. ".mp3", "GET", networkListener, params, "audio" .. contador .. ".mp3" ) end tm = timer.performWithDelay( 8000, esperar, 1000 ) elseif phase == "did" then end end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) return scene
Any idea to solve this problem?