change (add) the tray MM icon options?

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

keiju

change (add) the tray MM icon options?

Post by keiju »

I would like to know if there´s any script that allows to choose what options you get when you hit the MM tray icon. I would love to get an Edit Mood option there.

I searched the forum with no luck. Any of you know a way to get this done?

Thanks in advance
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

It depends on what you want exactly, but new items can be added to the tray menu in the same way as this happens for normal menus in MediaMonkey.

So adding a new item is no problem. The thing is, what do you want to happen if the item is clicked? Or is it a menu item with subitems?

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

I think the request is for a "My Moods" submenu that works in the same way as the "My Rating" one, when you right click on the tray icon.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Because the Mood icon is unavailable for menus, an other one is used. If necessary, the right icon can be included as separate file.
I used "Mood" instead of "My Moods..." text, because the first one is localisable, the second is not. Of course you can change this text to what you want.

This script requires MM 2.5.3 or newer, because that version includes the new LocalizeGen method and because a bug (that caused changing the mood through scripting didn't have any effect) has been fixed.

Code: Select all

Option Explicit

Sub OnStartup

    Dim MI
    Set MI = SDB.UI.AddMenuItemSub(SDB.UI.Menu_TrayIcon, 1, 2)
    MI.Caption = SDB.Localize("Mood")
    MI.IconIndex = 31
    Script.RegisterEvent MI, "OnClick", "MIClick"

End Sub


Sub MIClick(MI)
' Fill the tray moods list
' and check the mood for the currently playing song

    Dim Iter, MSI
    Set Iter = SDB.Database.OpenSQL("SELECT TextData FROM Lists WHERE IDListType=2 ORDER BY SortOrder")

    Dim LocalisedMood
    Do While Not Iter.EOF
        LocalisedMood = SDB.LocalizeGen("DB", Iter.StringByIndex(0))
        If SDB.Objects("TrayMoods_" & LocalisedMood) Is Nothing Then
            Set MSI = SDB.UI.AddMenuItem(MI, 0, 0)
            MSI.Caption = LocalisedMood
            MSI.IconIndex = 31
            Script.RegisterEvent MSI, "OnClick", "MSIClick"
            Set SDB.Objects("TrayMoods_" & LocalisedMood) = MSI
        End If
        SDB.Objects("TrayMoods_" & LocalisedMood).Checked = False
        Iter.Next
    Loop

    Dim CurrentSong : Set CurrentSong = SDB.Player.CurrentSong
    If Not CurrentSong Is Nothing Then
        If CurrentSong.Mood <> "" Then
            If Not SDB.Objects("TrayMoods_" & CurrentSong.Mood) Is Nothing Then
                SDB.Objects("TrayMoods_" & CurrentSong.Mood).Checked = True
            End If
        End If
    End If

End Sub


Sub MSIClick(MSI)
' Store the chosen mood to the song's properties

    Dim CurrentSong : Set CurrentSong = SDB.Player.CurrentSong
    If Not CurrentSong Is Nothing Then
        CurrentSong.Mood = MSI.Caption

	Dim SongList : Set SongList = SDB.NewSongList
	Call SongList.Add(CurrentSong)
	Call SongList.UpdateAll
    End If

End Sub
Cheers
Steegy
Last edited by Steegy on Sat May 27, 2006 8:22 am, edited 5 times in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

Steegy wrote:I don't know if this is already possible, but in the future it might be possible to fill the tray-sublist each time it is opened, so it is always correct.
Have a look here. It workes that way. :wink:
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Is the OnClick event raised even if the parent menu is not clicked, but just hovered (mouse-over)?

BTW: I was just trying out your script, when I saw this other post (multi-artist thread).

EDIT: Never mind the above question... aparently it works.
EDIT2: The above code has been changed so it now checks the current mood in the submenu, and it loads the moods list when the menu is opened, so it's always actual.
EDIT3: An improvement would be to drop the dictionary usage, but that's for a next version.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
keiju

Post by keiju »

Big THANKS guys... im sorry for not posting before but i just returned from a time away from the computer.

Then there´s no way to get the Mood Field written? I Have all custom fields in use already :(
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Well, I have posted about this problem in the debug forum, but I've got no responce yet. Maybe bumping that thread will make that someone responds...
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

@Jiri

Is it anyhow possible to localize the Moods, Occasions, Tempos (in DB.mo).
SDB.Localize only uses the default.mo :cry:
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

I possibly will make a fool out of myself here :)

I just found that MM database do not feature any Mood/Tempo storage.

I DID MAKE A FOOL OF MYSELF! :oops:
Message edited to save space....
Last edited by DiddeLeeDoo on Tue Apr 25, 2006 5:18 am, edited 1 time in total.
Image
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Mood, Tempo, ... *are* stored in the DB.

The list table gives, as you said, a list of all possible entries (and each entry has an ID)
In the AddSongInfoInt table, the actual references to the List table are stored for each song in the database (that has a mood, tempo, ... defined). The IntData column is linked to List.ID.

So to find the a certain characteristic of a song, you look in the Songs table to get it's ID. With that ID, you search the matching IDSong in the AddSongInfoInt table. You will then possibly see different entries for the same song, with different IntData fields. Each IntData field represents a certain characteristic that is linked to the ID of the List table.

E.g., if you want to find all songs matching a certain characteristic (from the PlayHotkeys_v1.0.vbs/Utility_SQL.vbs script)

Code: Select all

' Returns a SDBSongIterator object (EOF/Item/Next) for all songs with the specified InfoIntValue
Public Function SQLGetSongsInfoInt(InfoIntValue)

   Set SQLGetSongsInfoInt = SDB.Database.QuerySongs("AND Songs.ID IN (SELECT Songs.ID FROM ((Lists INNER JOIN AddSongInfoInt ON Lists.ID = AddSongInfoInt.IntData) INNER JOIN Songs ON AddSongInfoInt.IDSong = Songs.ID) INNER JOIN Artists ON Songs.IdArtist = Artists.ID WHERE Lists.TextData = '" & InfoIntValue & "')")

End Function
maybe code can be made "easier" like "SELECT blablabla FROM foo, bar, baz ...", but the above way seems to be the preferred sql way.

See the "scripting resources" (link in my signature) to find a text file with the database locations for (almost) all available track properties.

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Thank you, sitting here to try to catch up with you here, as I'd like to help if I can.

Potential solution:

Code: Select all

SELECT TextData FROM Lists WHERE ID < 39  AND IDListType=2 ORDER BY SortOrder
to keep to the standard translated moods. But that may be a silly solution.

Another thing, I believe there should be a Localize in the loop in order to look-up the translated value for mood 'Upbeat' for example.

Then something about, if translated value do not exist, use value in Lists.

This bit seems to be missing an object if song already have a different value.
If SDB.Player.CurrentSong.Mood <> "" Then
SDB.Objects("TrayMoods_" & SDB.Player.CurrentSong.Mood).Checked = True
End If

I've been sitting here trying to catch up with you folks on this issue, but I see this is for experts really. Sorry to stuff up your thread.
Image
jiri
Posts: 5417
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

As for Localize method - it really works for the main language file only. In MM 2.5.3 LocalizeGen() will be added and it will be possible to specify the language file to use (e.g. that 'DB').

Jiri
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Thanks.

Once that version comes out, I'll change the line

Code: Select all

LocalisedMood = SDB.Localize(Iter.StringByIndex(0)) 
to

Code: Select all

LocalisedMood = SDB.LocalizeGen( "DB", Iter.StringByIndex(0))
(updated according to jiri's post)

In the updated code above, I fixed the "no currentsong error" problem, and got rid of the dictionary.

@DiddeLeeDoo, "for your information":
- I want the mood tray menu to look exactly the same as the mood toolbar menu, so this new LocalizeGen seems the only solution to the problem. I want to include all available moods.
- SDB.Localize("TextToLocalize") returns the translated text of TextToLocalize. If there is no translation available, it automaticly returns the specified text TextToLocalize.

Thanks for the help.
Last edited by Steegy on Tue Apr 25, 2006 1:46 pm, edited 2 times in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
jiri
Posts: 5417
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

Just to help you in faster code update, it will be:

Code: Select all

LocalisedMood = SDB.LocalizeGen( "DB", Iter.StringByIndex(0))
Jiri
Post Reply