- Code: Select all
Module Script
Private t As XTimer = new XTimer(5000)
Public SongOld, SongNew As String
Public Sub Main(Action As String)
if (Action = "Start") then
SongOld = Xlobby.GetXlobbyVar("audioplayer>now>%artist%")
t.StartTimer
Else if (Action = "Stop") then
t.StopTimer
End if
End Sub
End Module
Class XTimer
' *** The system timer
Private t As System.Timers.Timer
' *** The class constructor
Public Sub New(pElapsed As Integer)
' *** Initialize the timer
t = new System.Timers.Timer(pElapsed)
' *** Add the event handler
AddHandler t.Elapsed, AddressOf TimerFired
End Sub
' *** Starts the timer
Public Sub StartTimer()
t.Enabled = true
End Sub
' *** Stops the timer
Public Sub StopTimer()
t.Enabled = false
End Sub
' **** Executes when the elapsed event occurs
Public Sub TimerFired(ByVal Sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
SongNew = Xlobby.GetXlobbyVar("audioplayer>now>%artist%")
if( SongNew <> SongOld ) Then
Xlobby.SendCommand("category", "music", "artist", "audioplayer>now>%artist%")
SongOld = SongNew
End if
End Sub
End Class