Can anybody have a look onto the end of Sub EditRating? Do I have to release the memory again?
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: Predefined RATING Script v1.2
'
' AUTHOR: Ralf K.
' DATE: 26.08.2005
'
' NOTE: Idea taken from Pekes "Predefined Genre Script v1.0"
'
' INSTALL:
' - If wanted, change constants in the beginning of this file
' - Copy script to MM directory scripts\auto
'
' USE:
' - Press key 0 ...5 to rate the currently selected song(s)
' - If no song is selected then currently playing song is rated
'
' REMARK: Rating process now can be done very fast without additional mouse clicks:
' 1) Start playing a list
' 2) Make sure no tracks are selected (otherwise they catch the rating)
' 3) Listen to track; wind forward if needed with '3' on numeric pad
' 4) Press 0 ..5 on normal keyboard for rating
' 5) Jump to next song with '9' an numeric pad
' 6) Continue with step 3)
'
'==========================================================================
'==========================================================================
' Define some constants
'==========================================================================
'Set Value to TRUE/FALSE if you want to use HotKey modifiers
const Use_Shift = FALSE 'TRUE
const Use_Ctrl = FALSE 'TRUE
const Use_Alt = FALSE 'TRUE
'Icon to be used in the menu
const MenuIcon = 64 '=yellow star
'==========================================================================
' MediaMonkey on-start Procedure
'==========================================================================
Sub OnStartup
' --------------
' Build the hotkey modifier
' --------------
Dim HotKeyRing
HotKeyRing = ""
If Use_Shift Then
HotKeyRing = HotKeyRing&"Shift+"
End if
If Use_Ctrl Then
HotKeyRing = HotKeyRing&"Ctrl+"
End if
If Use_Alt Then
HotKeyRing = HotKeyRing&"Alt+"
End if
' ----------------
' Create a new edit menu entry
' ----------------
' first we make a separator
SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit, 0, 0
' then we add the new menu
Dim RatingMenu
Set RatingMenu = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0)
RatingMenu.caption = "Change Rating"
RatingMenu.IconIndex = MenuIcon
RatingMenu.useScript = Script.ScriptPath
' ----------------
' Create the sub menus
' ----------------
Dim RatingSubmenu(5)
Dim i
for i = 0 to 5
Set RatingSubmenu(i) = SDB.UI.AddMenuItem(RatingMenu,0,0)
RatingSubmenu(i).Caption = i & " Star"
RatingSubmenu(i).OnClickFunc = "PredefinedRating"
RatingSubmenu(i).UseScript = Script.ScriptPath
RatingSubmenu(i).IconIndex = MenuIcon
RatingSubmenu(i).ShortCut = HotKeyRing&i
Next
End Sub
'==========================================================================
' Helper and callback procedure
'==========================================================================
Sub EditRating(i_rating)
Dim songlist, song, i
' ---------------
' First check which songs to alter
' ---------------
If SDB.SelectedSongList.count > 0 Then
Set songlist = SDB.SelectedSongList
elseif SDB.Player.CurrentSongIndex >= 0 then
Set songlist = SDB.NewSongList
songlist.Add(SDB.Player.CurrentSong)
else
Result = SDB.MessageBox("No tracks selected!", mtError, Array(mbOk))
Exit Sub
End If
' ---------------
' Change the songs rating
' ---------------
For i = 0 To songlist.count-1
Set song = songlist.Item(i)
song.Rating = i_rating
song.UpdateDB 'update MM database
song.WriteTags 'write data to file tag
Next
' free memory again??
' songlist = nothing
End Sub
Sub PredefinedRating(i_menuItem)
' Rating varies from 0 (= 0 stars) to 100 (= 5 stars)
' So we multiply caption (= 0...5) with 20
EditRating(Left(i_menuItem.Caption,1)*20)
End Sub