ISDBApplicationEvents::OnTrackProperties: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
(added note and script example)
mNo edit summary
Line 1: Line 1:
{{MethodDeclaration|SDBApplication|ISDBApplicationEvents|Sub OnTrackProperties(TrackList As SDBSongList)}}
{{MethodDeclaration|SDBApplication|ISDBApplicationEvents|Sub OnTrackProperties(TrackList As [[SDBSongList]])}}


===Parameters===
===Parameters===
Line 8: Line 8:
===Event description===
===Event description===


Is called whenever track(s) metadata were modified. This happens a lot, so use this event wisely. Unregister the event when your script doesn't need to handle it anymore.
Is called whenever track(s) metadata were modified. This happens a lot, so use this event wisely. [[ISDBScriptControl::UnRegisterEvents|Unregister]] the event when your script doesn't need to handle it anymore.


'''Note:''' If you modify track(s) metadata within the event handler, the event handler will be called again. Be sure to prevent the event handler from executing, otherwise this would cause an infinite loop. See the example below.
'''Note:''' If you modify track(s) metadata within the event handler, the event handler will be called again. Be sure to prevent the event handler from executing, otherwise this would cause an infinite loop. See the example below.

Revision as of 18:33, 26 December 2007

CoClass SDBApplication, Interface ISDBApplicationEvents

Sub OnTrackProperties(TrackList As SDBSongList)


Parameters

Name Type Description
TrackList SDBSongList A list of tracks that were modified.


Event description

Is called whenever track(s) metadata were modified. This happens a lot, so use this event wisely. Unregister the event when your script doesn't need to handle it anymore.

Note: If you modify track(s) metadata within the event handler, the event handler will be called again. Be sure to prevent the event handler from executing, otherwise this would cause an infinite loop. See the example below.

Example code

Script.RegisterEvent SDB, "OnTrackProperties", "SDB_OnTrackProperties" 


Dim InEventHandler : InEventHandler = False ' Control variable (shows if event handler is executing)

Sub SDB_OnTrackProperties(TrackList) 
    If InEventHandler Then Exit Sub         ' Prevent executing event handler from within itself
    
    InEventHandler = True                   ' Event starts --> set control variable

    ' make some changes to tracks in TrackList 

    TrackList.UpdateAll                     ' By applying the changes, the event handler will we called
    InEventHandler = False                  ' Event finished --> clear control variable
End Sub