ISDBApplicationEvents::OnTrackProperties: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
mNo edit summary
m (event called after data saved to db)
 
Line 9: Line 9:


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.
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.
<br />Event is called '''after''' data were saved to the database.


'''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.

Latest revision as of 21:27, 5 July 2008

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.
Event is called after data were saved to the database.

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