我正在尝试创建 3 个间隔为 10 秒的通知。但是,它只播放第一个声音,并以 10 秒的间隔永远重复。你能检查我的代码并告诉我我做错了什么吗?
local futureTime = 10 --10 seconds
local sounds = {"Icebaby.mp3", "Pokemon.mp3", "Yoshi.mp3"}
i=1
local options = {
alert = "Wake up!",
sound = "Icebaby.mp3" ,
custom = { msg = "Alarm" }
}
local notificationID = system.scheduleNotification( futureTime, options )
local function notificationListener( event )
system.cancelNotification(notificationID)
i=i+1
options.sound=sounds[i]
if(i>3) then
Runtime:removeEventListener ( "notification", notificationListener )
else
notificationID = system.scheduleNotification( futureTime, options )
end
end
Runtime:addEventListener( "notification", notificationListener )