View recent posts | Search forum topics
Hi everyone!
Is there some way to play an mp3 file in loop mode?
I've read the API doc but it seems to me that such feature is not yet available. Am I wrong?
Thank you,
Hugo.
I answer to myself,
The trick or workaround is to use timer.performWithDelay
This works if you are using sounds with the same lenght.
Here is the code I'm going to use in our second Corona SDK Tutorial at www.macsoluciones.com (a kind of "relaxing sounds" app for the iPhone ;-) )
--- code --- local ui = require("ui")
display.setStatusBar(display.HiddenStatusBar) local dst = display.newImage("fondo.png") local src = display.newImage("fondob.png")
local reproduce = function (event)
media.playSound(event.id)
end
local transicion = function()
transition.dissolve(src,dst,2000,1000)
src, dst = dst, src
local acampada = ui.newButton {
default = "buttonRed.png", over = "buttonRedOver.png", onEvent = reproduce, text = "Acampada", id = "acampada.mp3", emboss = true }
local bosque = ui.newButton {
default = "buttonRed.png", over = "buttonRedOver.png", onEvent = reproduce, text = "Bosque", id = "bosque.mp3", emboss = true }
local cascada = ui.newButton {
default = "buttonRed.png", over = "buttonRedOver.png", onEvent = reproduce, text = "Cascada", id = "cascada.mp3", emboss = true }
local grillos = ui.newButton {
default = "buttonRed.png", over = "buttonRedOver.png", onEvent = reproduce, text = "Grillos", id = "grillos.mp3", emboss = true }
local lluvia = ui.newButton {
default = "buttonRed.png", over = "buttonRedOver.png", onEvent = reproduce, text = "Lluvia", id = "lluvia.mp3", emboss = true }
acampada.x = 160 acampada.y = 80
bosque.x = 160 bosque.y = 160
cascada.x = 160 cascada.y = 240
grillos.x = 160 grillos.y = 320
lluvia.x = 160 lluvia.y = 400
timer.performWithDelay( 7000, reproduce,0 ) timer.performWithDelay( 20000, transicion,0 )
--- end of code ---
I answer to myself,
The trick or workaround is to use timer.performWithDelay
This works if you are using sounds with the same lenght.
Here is the code I'm going to use in our second Corona SDK Tutorial at www.macsoluciones.com (a kind of "relaxing sounds" app for the iPhone ;-) )
--- code ---
local ui = require("ui")
display.setStatusBar(display.HiddenStatusBar)
local dst = display.newImage("fondo.png")
local src = display.newImage("fondob.png")
local reproduce = function (event)
media.playSound(event.id)
end
local transicion = function()
transition.dissolve(src,dst,2000,1000)
src, dst = dst, src
end
local acampada = ui.newButton {
default = "buttonRed.png",
over = "buttonRedOver.png",
onEvent = reproduce,
text = "Acampada",
id = "acampada.mp3",
emboss = true
}
local bosque = ui.newButton {
default = "buttonRed.png",
over = "buttonRedOver.png",
onEvent = reproduce,
text = "Bosque",
id = "bosque.mp3",
emboss = true
}
local cascada = ui.newButton {
default = "buttonRed.png",
over = "buttonRedOver.png",
onEvent = reproduce,
text = "Cascada",
id = "cascada.mp3",
emboss = true
}
local grillos = ui.newButton {
default = "buttonRed.png",
over = "buttonRedOver.png",
onEvent = reproduce,
text = "Grillos",
id = "grillos.mp3",
emboss = true
}
local lluvia = ui.newButton {
default = "buttonRed.png",
over = "buttonRedOver.png",
onEvent = reproduce,
text = "Lluvia",
id = "lluvia.mp3",
emboss = true
}
acampada.x = 160
acampada.y = 80
bosque.x = 160
bosque.y = 160
cascada.x = 160
cascada.y = 240
grillos.x = 160
grillos.y = 320
lluvia.x = 160
lluvia.y = 400
timer.performWithDelay( 7000, reproduce,0 )
timer.performWithDelay( 20000, transicion,0 )
--- end of code ---