#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=B4X_ExampleAudio.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private B4XImageView1 As B4XImageView
Private B4XImageView2 As B4XImageView
Private Button1 As B4XView
Private playingMusic As Boolean
Private mp As MediaPlayer
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
B4XImageView1.Load(File.DirAssets, "disco.png")
B4XImageView2.Load(File.DirAssets, "background.jpg")
playingMusic = False
Button1.Text = "Play " & Chr(0xF04B)
Button1.Font = xui.CreateFontAwesome(22)
Button1.TextColor = xui.Color_White
Button1.SetColorAndBorder(0xFF55230C, 0, 0, 10dip)
#if b4a
mp.Initialize2("mp")
mp.Load(File.DirAssets, "audio.mp3")
mp.Looping = True
#else if b4i
mp.Initialize(File.DirAssets, "audio.mp3", "mp")
mp.Volume = 1
mp.Looping = True
#End If
End Sub
Private Sub Button1_Click
play
End Sub
Sub play
If playingMusic Then
playingMusic = False
Button1.Text = "Play " & Chr(0xF04B)
Return
End If
playingMusic = True
Button1.Text = "Stop " & Chr(0xF04D)
mp.Play
Do While playingMusic
For i = 1 To 90
B4XImageView1.mBase.Rotation = (i*4)
Sleep(50)
If playingMusic = False Then
mp.Pause
Exit
End If
Next
Loop
End Sub
Private Sub mp_Complete
Log("mp_Complete")
End Sub
Private Sub mp_EndInterruption
Log("mp_EndInterruption")
End Sub