locked
How to add background music to a program? RRS feed

  • Question

  • Hi Team,

    How to add background music to a program using Small Basic till the program ends?

    Thanks






    Sunday, December 3, 2017 10:41 AM

Answers

  • Perhaps like this:

    musicFile = "http://litdev.co.uk/game_images/backgroundMusic.mp3"
    Timer.Interval = 70000 'ms the music lasts For
    Timer.Tick = OnTimer
    startMusic = "True"
    
    While ("True")
    	If (startMusic) Then 'Start and stop must on UI thread, NOT inside an event
    		startMusic = "False"
    		Sound.Stop(musicFile) 'Stop must first - allows it to be started from the begiining
    		Sound.Play(musicFile)
    	EndIf
    	
    	Program.Delay(20)
    EndWhile
    
    Sub OnTimer
    	startMusic = "True"
    EndSub

    • Marked as answer by [Roshan_Kumar] Sunday, December 3, 2017 12:43 PM
    Sunday, December 3, 2017 11:29 AM