Sample Event Handlers script: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(fixed link) |
||
Line 38: | Line 38: | ||
</source> | </source> | ||
As of MediaMonkey 4, events can also be received by external programs. See [[ | As of MediaMonkey 4, events can also be received by external programs. See [[Python event handling|this example]], using Python. |
Latest revision as of 15:52, 20 July 2011
' This script shows how to use COM events in MediaMonkey scripting.
' You can associate event with a VB procedure and cancel the association later.
Sub OnStartup
Script.RegisterEvent SDB, "OnShutdown", "SDBShutdown"
Script.RegisterEvent SDB, "OnTrackProperties", "SDBTrackProperties"
Script.RegisterEvent SDB, "OnPlay", "SDBPlay"
Script.RegisterEvent SDB, "OnPause", "SDBPause"
Set Tmr = SDB.CreateTimer( 10000) ' Pop up a message in 10 seconds
Script.RegisterEvent Tmr, "OnTimer", "TestTimer"
End Sub
Sub SDBTrackProperties( tracks)
SDB.MessageBox "Wow, track properties were modified for "&tracks.count&" track(s)!", mtInformation, Array(mbOk)
' Script.UnregisterEvents SDB
End Sub
Sub SDBShutdown
SDB.MessageBox "MediaMonkey is finishing... :(", mtInformation, Array(mbOk)
End Sub
Sub SDBPlay
SDB.MessageBox "Started playback of "&SDB.Player.CurrentSong.ArtistName&_
" - "&SDB.Player.CurrentSong.Title, mtInformation, Array(mbOk)
End Sub
Sub SDBPause
If SDB.Player.isPaused Then
SDB.MessageBox "Playback paused", mtInformation, Array(mbOk)
End If
End Sub
Sub TestTimer( Timer)
SDB.MessageBox "10 seconds elapsed!", mtInformation, Array(mbOk)
Script.UnregisterEvents Timer ' Terminate usage of this timer
End Sub
As of MediaMonkey 4, events can also be received by external programs. See this example, using Python.