change (add) the tray MM icon options?

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

keiju

change (add) the tray MM icon options?

Post by keiju » Mon Apr 03, 2006 5:13 pm

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
Location: Belgium
Contact:

Post by Steegy » Mon Apr 03, 2006 5:46 pm

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: Barton, UK
Contact:

Post by trixmoto » Tue Apr 04, 2006 3:19 am

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.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Tue Apr 04, 2006 5:09 am

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: 2146
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno » Tue Apr 04, 2006 5:14 am

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:
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Tue Apr 04, 2006 5:18 am

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 » Sat Apr 15, 2006 5:40 am

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
Location: Belgium
Contact:

Post by Steegy » Sat Apr 15, 2006 7:01 am

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: 2146
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno » Mon Apr 24, 2006 5:01 am

@Jiri

Is it anyhow possible to localize the Moods, Occasions, Tempos (in DB.mo).
SDB.Localize only uses the default.mo :cry:
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Mon Apr 24, 2006 9:09 am

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
Location: Belgium
Contact:

Post by Steegy » Mon Apr 24, 2006 12:20 pm

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 » Mon Apr 24, 2006 5:16 pm

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

mockturtle
Posts: 8
Joined: Wed Jun 18, 2008 4:49 pm

Post by mockturtle » Tue Apr 25, 2006 10:31 am

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
Location: Belgium
Contact:

Post by Steegy » Tue Apr 25, 2006 1:31 pm

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

mockturtle
Posts: 8
Joined: Wed Jun 18, 2008 4:49 pm

Post by mockturtle » Tue Apr 25, 2006 1:34 pm

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

Code: Select all

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

Post Reply