//Called when application is started. function OnStart() { //Create a layout with objects vertically centered. lay = app.CreateLayout( "linear", "VCenter,FillXY" ); //Create a button. btn = app.CreateButton( "Send To Back", 0.6 ); btn.SetOnTouch( btn_OnTouch ); lay.AddChild( btn ); //Add layout to app. app.AddLayout( lay ); //Create media player. player = app.CreateMediaPlayer(); //Load a file (can be ogg or mp3). player.SetFile( "/Sys/Snd/Poing.ogg" ); player.SetLooping( true ); } //Called when user touches our button. function btn_OnTouch() { //Set alarm for 5 seconds time. var now = new Date().getTime(); app.SetAlarm( "Set", 1234, OnAlarm, now + 5000 ); //Set sound playing repeatedly. //setInterval( PlaySound, 1000 ); player.Play(); //Send app to back. app.ToBack(); } //Called when alarm is triggered. //(Even if your app is closed) function OnAlarm() { app.ShowPopup( "Hello!" ); } //Play the sound. function PlaySound() { player.SeekTo( 0 ); player.Play(); }