This script should not be necessary anymore.
:: LibraryPanes' own forum post.
Note: MediaMonkey v3 and above will have something similar included natively.
Preview version: Only works without problems on MM 2.5.3 RC4 or newer.
If anyone is getting error messages about line 184 or 192, send a blank email to fixlp@trixmoto.net and you should recieve the fix instantly!
(This address is not checked and the emails are deleted, an auto response is sent with the fix!)
Description:
The LibraryPanes script adds a dockable panel with Library Panes (browse library like in Winamp, iTunes, JRiverMC, ...) to the user interface.
The panel consists of a Custom pane, an Artists and an Albums pane. The custom pane's function can be chooses between: Genre, Tempo, Mood, Occasion, Quality. It can be toggled on or off. The panel can be closed/reopened (e.g. menu View item), docked, ... and all controls automaticly resize.
A top tree node "Library Panes" is added and remembers the previous browse position.
A screenshot is added at the end of the post.
The script needs MediaMonkey version 2.5.3 or above.
Installing manually:
The script below is an auto-script. The Faq "How do I install scripts?" http://faq.mediamonkey.com/index.php?ac ... artlang=en explains how to install it.
Quicky: Copy the code below to a plain text file (e.g. using NotePad) and save it as LibraryPanes.vbs. Put that file un MediaMonkey's Scripts\Auto folder and (re)start MediaMonkey.
The script consists of 1 standalone script file ("LibraryPanes.vbs")
LibraryPanes.vbs (for the Scripts\Auto folder)
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: LibraryPanes v0.1.1
' DESCRIPTION:
' Adds a dockable panel with Library Panes (browse library like in Winamp, iTunes, JRiverMC, ...) to the user interface.
' The panel consists of a Custom pane, an Artists and an Albums pane. The custom pane's function can be chooses between:
' Genre, Tempo, Mood, Occasion, Quality. It can be toggled on or off.
' The panel can be closed/reopened (e.g. menu View item), docked, ... and all controls automaticly resize.
' A top tree node "Library Panes" is added and remembers the previous browse position
'
' AUTHOR: Steegy aka RC (Ruben Castelein)
' DATE : 04/06/2006
' UPDATE: 05/06/2006
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts\Auto" folder
'
' The script needs MediaMonkey version 2.5.3 or above.
'
'==========================================================================
'>> ForumURL:
'>> ScriptName: LibraryPanes
'>> VersionNumber: 0.1
'>> Author: Steegy aka RC (Ruben Castelein)
'>>>>EndOfProperties
' By design, selecting genres, artists and albums don't go to the corresponding nodes in the main tree
' Reasons are speed, flexibility, consistency, separate "library panes" node for easy memory of previous selection (like the search node, so e.g. also is saved in the tree history) and no useless mess with the tree node
' For more info, just ask me
' TODO:
' =====
' - Add option panel (to set the above options + to enable/disable "EnsureVisible")
' - Add option to not automaticly fill the tracks list (e.g. only fill it with explicit click in the albums pane)
' - Add ability to use Alt+Enter, Shift+Ctrl+Enter, Ctrl+Enter on the selected item
' - Add option to only show accessible tracks
' - Update listviews when tags have been changed (subscribe to SDB's OnTrackProperties event)
' - Add option to ignore prefixes like "The"
' - Add option to only show accessible artists/genres
' - Make entries editable (Now they "seem" editable, because of an issue with the listview control. They are not editable.)
'##############################################################################################
'*****************************************************
'**** GLOBAL DECLARATIONS ****
'*****************************************************
Option Explicit
'Dim LV : Set LV = CreateObject("COMCTL.ListViewCtrl") 'Only necessary for help functions
Const ForegroundColor = &H000000
Const BackgroundColor = &HEFEFEF
Dim TreeNode, ViewMenuItem, Panel
Dim lvCustom, lvArtists, lvAlbums
Dim chkShowCustomPane, ddnCustomPaneKind
Dim lblArtists, lblAlbums
Dim CustomPaneVisible, CustomPaneKind
Dim PreviousCustomItem, PreviousArtistsItem, PreviousAlbumsItem
Dim LastSelection
' ListView Constants
Const lvwReport = 3 'Show listview in "Report" view
Const lvwAutomatic = 0 'Only allow Automatic editing of labels (don't allow manual editing)
' Alignment constants (alignment of the control in its parent control)
Const alNone = 0 'No alignment is applied
Const alTop = 1 'Control is aligned to the top
Const alBottom = 2 'Control is aligned to the bottom
Const alLeft = 3 'Control is aligned to the left
Const alRight = 4 'Control is aligned to the right
Const alClient = 5 'Control completely covers its parent
' Anchors constants (control to which borders of the parent control the control is sticked)
Const akLeft = 1 'Distance from the left border of the parent is constant
Const akTop = 2 'Distance from the top border of the parent is constant
Const akRight = 4 'Distance from the right border of the parent is constant
Const akBottom = 8 'Distance from the bottom border of the parent is constant
'*****************************************************
'**** ENTRY POINT ****
'*****************************************************
Sub OnStartup
Set PreviousArtistsItem = Nothing
Set PreviousAlbumsItem = Nothing
LastSelection = " "
Call Initialise_LicenseFix
Call Initialise_TreeNode
Call Initialise_Panel 'Create the Panel before creating the ViewMenuItem (the ViewMenuItem Checked state depends on the Panel's Visible state)
Call Initialise_ViewMenuItem
Call Initialise_lvCustom
Call Initialise_lvArtists
Call Initialise_lvAlbums
Call Initialise_chkShowCustomPane
Call Initialise_ddnCustomPaneKind
If CustomPaneVisible Then
Call FilllvCustom
End If
lvCustom.Interf.ListItems(1).Selected = True
Call DoCustom
Call OnPanelResize(Panel)
If SDB.IniFile.StringValue("LibraryPanes", "PanelVisible") = "False" Then
Panel.Common.Visible = False
Else
Panel.Common.Visible = True
End If
Script.RegisterEvent Panel.Common, "OnResize", "OnPanelResize"
Script.RegisterEvent SDB, "OnChangedSelection", "OnChangedSelection"
End Sub
'*****************************************************
'**** INITIALISATION METHODS ****
'*****************************************************
Sub Initialise_LicenseFix
End Sub
Sub Initialise_TreeNode
Set TreeNode = SDB.MainTree.CreateNode
Set SDB.Objects("LibraryPanes_TreeNode") = TreeNode
TreeNode.Caption = "Library Panes"
TreeNode.IconIndex = 46
SDB.MainTree.AddNode SDB.MainTree.Node_MyComputer, TreeNode, 1
Script.RegisterEvent TreeNode, "OnFillTracks", "OnFillTracks"
End Sub
Sub Initialise_Panel
Set Panel = SDB.UI.NewDockablePersistentPanel("LibraryPanes_Panel")
Set SDB.Objects("LibraryPanes_Panel") = Panel
If Panel.IsNew Then
Panel.DockedTo = 2
Panel.Common.Width = 430
Panel.Common.Height = 30
End If
Panel.Caption = "LibraryPanes"
Script.RegisterEvent Panel, "OnClose", "OnPanelClose"
End Sub
Sub Initialise_ViewMenuItem
Set ViewMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_View, 1, -3)
ViewMenuItem.Caption = "Show Library Panes"
ViewMenuItem.Checked = Panel.Common.Visible
ViewMenuItem.Hint = "Show the extra library panes"
Script.RegisterEvent ViewMenuItem, "OnClick", "MIClick"
End Sub
Sub Initialise_lvCustom
Set lvCustom = SDB.UI.NewActiveX(Panel, "COMCTL.ListViewCtrl")
lvCustom.Common.Left = 0
lvCustom.Common.Top = 20
'lvCustom.Common.Width = Panel.Common.Width / 2 'Also automatcily set by the panel's OnResize event handler
lvCustom.Common.Height = Panel.Common.ClientHeight - 20
lvCustom.Common.Anchors = 1+2+8
lvCustom.Interf.View = lvwReport
lvCustom.Interf.LabelEdit = lvwAutomatic
lvCustom.Interf.HideSelection = False
lvCustom.Interf.HideColumnHeaders = True
lvCustom.Interf.BackColor = BackgroundColor
lvCustom.Interf.ForeColor = ForegroundColor
Call lvCustom.Interf.ColumnHeaders.Add(, , "Custom", lvCustom.Common.Width - 50)
Call lvCustom.Interf.ListItems.Add( , , "<< All >>")
lvCustom.Interf.ListItems(1).Tag = "ALL"
Script.RegisterEvent lvCustom.Interf, "ItemClick", "OnCustomSelect"
End Sub
Sub Initialise_lvArtists
Set lblArtists = CreateLabel(Panel, "Artists", 0, 5, 50, 20)
lblArtists.Common.Anchors = 2
Set lvArtists = SDB.UI.NewActiveX(Panel, "COMCTL.ListViewCtrl")
'lvArtists.Common.Left = 0 'Also automatcily set by the panel's OnResize event handler
lvArtists.Common.Top = 20
'lvArtists.Common.Width = Panel.Common.Width / 2 'Also automatcily set by the panel's OnResize event handler
lvArtists.Common.Height = Panel.Common.ClientHeight - 20
lvArtists.Common.Anchors = 2+8
lvArtists.Interf.View = lvwReport
lvArtists.Interf.LabelEdit = lvwAutomatic
lvArtists.Interf.HideSelection = False
lvArtists.Interf.HideColumnHeaders = True
lvArtists.Interf.BackColor = BackgroundColor
lvArtists.Interf.ForeColor = ForegroundColor
Call lvArtists.Interf.ColumnHeaders.Add(, , "Artists", lvArtists.Common.Width - 50)
Script.RegisterEvent lvArtists.Interf, "ItemClick", "OnArtistSelect"
End Sub
Sub Initialise_lvAlbums
Set lblAlbums = CreateLabel(Panel, "Albums", 0, 5, 50, 20)
lblAlbums.Common.Anchors = 2
Set lvAlbums = SDB.UI.NewActiveX(Panel, "COMCTL.ListViewCtrl")
'lvAlbums.Common.Left = lvArtists.Common.Width
lvAlbums.Common.Top = 20
'lvAlbums.Common.Width = lvArtists.Common.Width - 15 'Also automatcily set by the panel's OnResize event handler
lvAlbums.Common.Height = Panel.Common.ClientHeight - 20
lvAlbums.Common.Anchors = 2+8
lvAlbums.Interf.View = lvwReport
lvAlbums.Interf.LabelEdit = lvwAutomatic
lvAlbums.Interf.HideSelection = False
lvAlbums.Interf.HideColumnHeaders = True
lvAlbums.Interf.BackColor = BackgroundColor
lvAlbums.Interf.ForeColor = ForegroundColor
Call lvAlbums.Interf.ColumnHeaders.Add(, , "Albums", lvAlbums.Common.Width - 50)
Script.RegisterEvent lvAlbums.Interf, "ItemClick", "OnAlbumSelect"
End Sub
Sub Initialise_chkShowCustomPane
Set chkShowCustomPane = CreateCheckBox(Panel, "Xtra", 0, 1, 40, 20, "chkShowCustomPane")
If SDB.IniFile.StringValue("LibraryPanes", "CustomPaneVisible") = "" Then
CustomPaneVisible = False
Else
CustomPaneVisible = SDB.IniFile.StringValue("LibraryPanes", "CustomPaneVisible")
End If
chkShowCustomPane.Checked = CustomPaneVisible
lvCustom.Common.Visible = CustomPaneVisible
Script.RegisterEvent chkShowCustomPane.Common, "OnClick", "OnchkShowCustomPaneClick"
End Sub
Sub Initialise_ddnCustomPaneKind
Set ddnCustomPaneKind = CreateDropDown(Panel, 0, 0, 200, 20, "ddnCustomPaneKind")
ddnCustomPaneKind.Style = csDropDownList
Dim CustomList : CustomList = Array("Genres", "Tempo", "Mood", "Occasion", "Quality")
Call FillDropDownFromArray(ddnCustomPaneKind, CustomList)
CustomPaneKind = SDB.IniFile.StringValue("LibraryPanes", "CustomPaneKind")
If CustomPaneKind = "" Then
CustomPaneKind = "Genres"
End If
Call SelectDropDownText(ddnCustomPaneKind, CustomPaneKind)
ddnCustomPaneKind.Common.Visible = CustomPaneVisible
Script.RegisterEvent ddnCustomPaneKind, "OnSelect", "OnddnCustomPaneKindSelect"
End Sub
'*****************************************************
'**** EVENT HANDLING METHODS ****
'*****************************************************
Sub MIClick(ViewMenuItem)
ViewMenuItem.Checked = Not ViewMenuItem.Checked
Panel.Common.Visible = ViewMenuItem.Checked
SDB.IniFile.StringValue("LibraryPanes", "PanelVisible") = ViewMenuItem.Checked
End Sub
Sub OnddnCustomPaneKindSelect(ddnCustomPaneKind)
Call SDB.ProcessMessages
CustomPaneKind = ddnCustomPaneKind.Text
SDB.IniFile.StringValue("LibraryPanes", "CustomPaneKind") = CustomPaneKind
Call lvCustom.Interf.ListItems.Clear
Call lvCustom.Interf.ListItems.Add( , , "<< All >>")
lvCustom.Interf.ListItems(1).Tag = "ALL"
Call FilllvCustom
Call DoCustom
End Sub
Sub OnchkShowCustomPaneClick(chkShowCustomPane)
Call SDB.ProcessMessages
CustomPaneVisible = chkShowCustomPane.Checked
SDB.IniFile.StringValue("LibraryPanes", "CustomPaneVisible") = CustomPaneVisible
ddnCustomPaneKind.Common.Visible = CustomPaneVisible
lvCustom.Common.Visible = CustomPaneVisible
Call OnPanelResize(Panel)
If lvCustom.Interf.ListItems.Count = 1 Then
Call FilllvCustom
End If
lvCustom.Interf.ListItems(1).Selected = True
If PreviousCustomItem Is Nothing Then
Call DoCustom
Else
If lvCustom.Interf.SelectedItem.Tag <> PreviousCustomItem.Tag Then
Call DoCustom
End If
End If
End Sub
Sub OnPanelClose(Panel)
ViewMenuItem.Checked = False
SDB.IniFile.StringValue("LibraryPanes", "PanelVisible") = "False"
End Sub
Sub OnFillTracks(TreeNode)
Call SDB.ProcessMessages
If Not Panel.Common.Visible Then
Panel.Common.Visible = True
ViewMenuItem.Checked = True
SDB.IniFile.StringValue("LibraryPanes", "PanelVisible") = "True"
End If
Select Case LastSelection
Case "Custom": Call DoCustom
Case "Artists": Call DoArtists
Case "Albums", "": Call DoAlbums
Case " ":
Call DoAlbums
If Not lvArtists.Interf.SelectedItem Is Nothing Then
lvArtists.Interf.SelectedItem.Selected = True
Call lvArtists.Interf.SelectedItem.EnsureVisible
End If
If Not lvAlbums.Interf.SelectedItem Is Nothing Then
lvAlbums.Interf.SelectedItem.Selected = True
Call lvAlbums.Interf.SelectedItem.EnsureVisible
End If
End Select
End Sub
Sub OnCustomSelect(ListItem)
Call SDB.ProcessMessages
If EqualNodes(SDB.MainTree.CurrentNode, TreeNode) Then
If Not PreviousCustomItem Is Nothing Then
If lvCustom.Interf.SelectedItem.Tag = PreviousCustomItem.Tag Then Exit Sub
End If
LastSelection = "Custom"
Call SDB.MainTracksWindow.Refresh
Else
LastSelection = "Custom"
Set SDB.MainTree.CurrentNode = TreeNode
End If
End Sub
Sub OnArtistSelect(ListItem)
Call SDB.ProcessMessages
If EqualNodes(SDB.MainTree.CurrentNode, TreeNode) Then
If Not PreviousArtistsItem Is Nothing Then
If lvArtists.Interf.SelectedItem.Tag = PreviousArtistsItem.Tag Then Exit Sub
End If
LastSelection = "Artists"
Call SDB.MainTracksWindow.Refresh
Else
LastSelection = "Artists"
Set SDB.MainTree.CurrentNode = TreeNode
End If
End Sub
Sub OnAlbumSelect(ListItem)
Call SDB.ProcessMessages
If EqualNodes(SDB.MainTree.CurrentNode, TreeNode) Then
If Not PreviousAlbumsItem Is Nothing Then
If lvAlbums.Interf.SelectedItem.Tag = PreviousAlbumsItem.Tag Then Exit Sub
End If
LastSelection = "Albums"
Call SDB.MainTracksWindow.Refresh
Else
LastSelection = "Albums"
Set SDB.MainTree.CurrentNode = TreeNode
End If
End Sub
Sub OnPanelResize(Panel)
If Panel.DockedTo = 0 Then Exit Sub ' Don't do anything when the panel is being (un)docked
Dim NumberOfPanes
If CustomPaneVisible Then
NumberOfPanes = 3
Else
NumberOfPanes = 2
End If
Dim PaneWidth : PaneWidth = Panel.Common.ClientWidth / NumberOfPanes
lvCustom.Common.Width = PaneWidth
If CustomPaneVisible Then
lvArtists.Common.Left = PaneWidth
Else
lvArtists.Common.Left = 0
End If
lvArtists.Common.Width = PaneWidth
lvAlbums.Common.Width = (Panel.Common.ClientWidth - (lvArtists.Common.Left + PaneWidth))
lvAlbums.Common.Left = lvArtists.Common.Left + PaneWidth
Dim HeaderWidth : HeaderWidth = Cond(0 > PaneWidth - 45, 0, PaneWidth - 45)
lvCustom.Interf.ColumnHeaders(1).Width = HeaderWidth
lvArtists.Interf.ColumnHeaders(1).Width = HeaderWidth
lvAlbums.Interf.ColumnHeaders(1).Width = HeaderWidth
ddnCustomPaneKind.Common.Width = lvCustom.Common.Width
lblArtists.Common.Width = lvArtists.Common.Width - 3
lblArtists.Common.Left = lvArtists.Common.Left + 5
lblAlbums.Common.Width = lvAlbums.Common.Width - 3
lblAlbums.Common.Left = lvAlbums.Common.Left + 5
chkShowCustomPane.Common.Left = Panel.Common.ClientWidth - chkShowCustomPane.Common.Width
End Sub
Sub OnChangedSelection
If Not EqualNodes(SDB.MainTree.CurrentNode, TreeNode) Then
Call DeselectListViews
End If
End Sub
'*****************************************************
'**** WORKER METHODS ****
'*****************************************************
Sub DoCustom
Call lvArtists.Interf.ListItems.Clear
Call lvAlbums.Interf.ListItems.Clear
Call SDB.ProcessMessages
Call lvArtists.Interf.ListItems.Add( , , "<< All >>")
lvArtists.Interf.ListItems(1).Selected = True
Dim RecordCount
If CustomTag = "ALL" Then
RecordCount = AddItemsFromQuery(lvArtists, "" _
+ "SELECT Artist, ID " _
+ "FROM Artists " _
+ "ORDER BY Artist")
Else
If CustomPaneKind = "Genres" Then
RecordCount = AddItemsFromQuery(lvArtists, "" _
+ "SELECT DISTINCTROW Artists.Artist, Artists.ID " _
+ "FROM Artists INNER JOIN (Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre) ON Artists.ID = Songs.IDArtist " _
+ "WHERE Genres.IDGenre=" + CustomTag + " " _
+ "ORDER BY Artists.Artist")
Else
RecordCount = AddItemsFromQuery(lvArtists, "" _
+ "SELECT DISTINCT Artists.Artist, Artists.ID " _
+ "FROM Lists INNER JOIN ((Artists INNER JOIN Songs ON Artists.ID = Songs.IDArtist) INNER JOIN AddSongInfoInt ON Songs.ID = AddSongInfoInt.IDSong) ON Lists.ID = AddSongInfoInt.IntData " _
+ "WHERE Lists.ID=" + CustomTag + " AND AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind))
End If
End If
lvArtists.Interf.ListItems(1).Text = "<< All (" & RecordCount & ") >>"
lvArtists.Interf.ListItems(1).Tag = "ALL"
Set PreviousCustomItem = lvCustom.Interf.SelectedItem
Set PreviousArtistsItem = lvArtists.Interf.SelectedItem
Set PreviousAlbumsItem = lvAlbums.Interf.SelectedItem
Call SDB.ProcessMessages
Call DoArtists
End Sub
Sub DoArtists
Call lvAlbums.Interf.ListItems.Clear
Call SDB.ProcessMessages
Call lvAlbums.Interf.ListItems.Add( , , "<< All >>")
lvAlbums.Interf.ListItems(1).Selected = True
Dim RecordCount
If CustomTag = "ALL" Then
If ArtistsTag = "ALL" Then
RecordCount = AddItemsFromQuery(lvAlbums, "" _
+ "SELECT Album, ID " _
+ "FROM Albums " _
+ "ORDER BY Album")
Else
RecordCount = AddItemsFromQuery(lvAlbums, "" _
+ "SELECT DISTINCTROW Albums.Album, Albums.ID " _
+ "FROM (Albums INNER JOIN Songs ON Albums.ID = Songs.IDAlbum) INNER JOIN Artists ON Songs.IDArtist = Artists.ID " _
+ "WHERE Artists.ID=" + ArtistsTag + " " _
+ "ORDER BY Albums.Album")
End If
Else
If CustomPaneKind = "Genres" Then
If ArtistsTag = "ALL" Then
RecordCount = AddItemsFromQuery(lvAlbums, "" _
+ "SELECT DISTINCTROW Albums.Album, Albums.ID " _
+ "FROM Albums INNER JOIN (Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre) ON Albums.ID = Songs.IDAlbum " _
+ "WHERE Genres.IDGenre=" + CustomTag + " " _
+ "ORDER BY Albums.Album")
Else
RecordCount = AddItemsFromQuery(lvAlbums, "" _
+ "SELECT DISTINCTROW Albums.Album, Albums.ID " _
+ "FROM Artists INNER JOIN (Albums INNER JOIN (Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre) ON Albums.ID = Songs.IDAlbum) ON Artists.ID = Songs.IDArtist " _
+ "WHERE (Genres.IDGenre=" + CustomTag + " AND Artists.ID=" + ArtistsTag + ") " _
+ "ORDER BY Albums.Album")
End If
Else
If ArtistsTag = "ALL" Then
RecordCount = AddItemsFromQuery(lvAlbums, "" _
+ "SELECT DISTINCT Albums.Album, Albums.ID " _
+ "FROM Albums INNER JOIN (Lists INNER JOIN (AddSongInfoInt INNER JOIN Songs ON AddSongInfoInt.IDSong = Songs.ID) ON Lists.ID = AddSongInfoInt.IntData) ON Albums.ID = Songs.IDAlbum " _
+ "WHERE AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind) & " AND Lists.ID=" + CustomTag)
Else
RecordCount = AddItemsFromQuery(lvAlbums, "" _
+ "SELECT DISTINCT Albums.Album, Albums.ID " _
+ "FROM (Albums INNER JOIN (Artists INNER JOIN Songs ON Artists.ID = Songs.IDArtist) ON (Songs.IDAlbum = Albums.ID)) INNER JOIN (Lists INNER JOIN AddSongInfoInt ON Lists.ID = AddSongInfoInt.IntData) ON Songs.ID = AddSongInfoInt.IDSong " _
+ "WHERE Artists.ID=" + ArtistsTag + " AND AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind) & " AND Lists.ID=" + CustomTag)
End If
End If
End If
lvAlbums.Interf.ListItems(1).Text = "<< All (" & RecordCount & ") >>"
lvAlbums.Interf.ListItems(1).Tag = "ALL"
Set PreviousArtistsItem = lvArtists.Interf.SelectedItem
Set PreviousAlbumsItem = lvAlbums.Interf.SelectedItem
Call SDB.ProcessMessages
Call DoAlbums
End Sub
Sub DoAlbums
If lvAlbums.Interf.SelectedItem Is Nothing Then Exit Sub
Call SDB.ProcessMessages
If CustomTag = "ALL" Then
If ArtistsTag = "ALL" Then
If AlbumsTag = "ALL" Then
Call SDB.MainTracksWindow.AddTracksFromQuery("")
Else
Call SDB.MainTracksWindow.AddTracksFromQuery("" _
+ "AND Albums.ID=" + AlbumsTag)
End If
Else
If AlbumsTag = "ALL" Then
Call SDB.MainTracksWindow.AddTracksFromQuery("" _
+ "AND Artists.ID=" + ArtistsTag)
Else
Call SDB.MainTracksWindow.AddTracksFromQuery("" _
+ "AND Artists.ID=" + ArtistsTag + " AND Albums.ID=" + AlbumsTag)
End If
End If
Else
If CustomPaneKind = "Genres" Then
If ArtistsTag = "ALL" Then
If AlbumsTag = "ALL" Then
Call AddTracksFromQueryAdvanced("" _
+ "SELECT Songs.ID " _
+ "FROM Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre " _
+ "WHERE Genres.IDGenre=" + CustomTag)
Else
Call AddTracksFromQueryAdvanced("" _
+ "SELECT Songs.ID " _
+ "FROM (Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre) INNER JOIN Albums ON Songs.IDAlbum = Albums.ID " _
+ "WHERE (Genres.IDGenre=" + CustomTag + " AND Albums.ID=" + AlbumsTag + ")")
End If
Else
If AlbumsTag = "ALL" Then
Call AddTracksFromQueryAdvanced("" _
+ "SELECT Songs.ID " _
+ "FROM Artists INNER JOIN (Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre) ON Artists.ID = Songs.IDArtist " _
+ "WHERE (Genres.IDGenre=" + CustomTag + " AND Artists.ID=" + ArtistsTag + ")")
Else
Call AddTracksFromQueryAdvanced("" _
+ "SELECT Songs.ID " _
+ "FROM (Artists INNER JOIN (Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre) ON Artists.ID = Songs.IDArtist) INNER JOIN Albums ON Songs.IDAlbum = Albums.ID " _
+ "WHERE (Genres.IDGenre=" + CustomTag + " AND Artists.ID=" + ArtistsTag + " AND Albums.ID=" + AlbumsTag + ")")
End If
End If
Else
If ArtistsTag = "ALL" Then
If AlbumsTag = "ALL" Then
Call AddTracksFromQueryAdvanced("" _
+ "SELECT DISTINCT Songs.ID " _
+ "FROM Lists INNER JOIN (AddSongInfoInt INNER JOIN Songs ON AddSongInfoInt.IDSong = Songs.ID) ON Lists.ID = AddSongInfoInt.IntData " _
+ "WHERE AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind) & " AND Lists.ID=" + CustomTag)
Else
Call AddTracksFromQueryAdvanced("" _
+ "SELECT DISTINCT Songs.ID " _
+ "FROM Albums INNER JOIN (Lists INNER JOIN (AddSongInfoInt INNER JOIN Songs ON AddSongInfoInt.IDSong = Songs.ID) ON Lists.ID = AddSongInfoInt.IntData) ON Albums.ID = Songs.IDAlbum " _
+ "WHERE AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind) & " AND Albums.ID=" + AlbumsTag + " AND Lists.ID=" + CustomTag)
End If
Else
If AlbumsTag = "ALL" Then
Call AddTracksFromQueryAdvanced("" _
+ "SELECT Songs.ID " _
+ "FROM Artists INNER JOIN (Albums INNER JOIN (Lists INNER JOIN (AddSongInfoInt INNER JOIN Songs ON AddSongInfoInt.IDSong = Songs.ID) ON Lists.ID = AddSongInfoInt.IntData) ON Albums.ID = Songs.IDAlbum) ON (Artists.ID = Songs.IDArtist) " _
+ "WHERE AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind) & " AND Lists.ID=" + CustomTag + " AND Artists.ID=" + ArtistsTag)
Else
Call AddTracksFromQueryAdvanced("" _
+ "SELECT Songs.ID " _
+ "FROM (Albums INNER JOIN (Artists INNER JOIN Songs ON Artists.ID = Songs.IDArtist) ON (Songs.IDAlbum = Albums.ID)) INNER JOIN (Lists INNER JOIN AddSongInfoInt ON Lists.ID = AddSongInfoInt.IntData) ON Songs.ID = AddSongInfoInt.IDSong " _
+ "WHERE Albums.ID=" + AlbumsTag + " AND Artists.ID=" + ArtistsTag + " AND AddSongInfoInt.DataType=1010" & GetIDListType(CustomPaneKind) & " AND Lists.ID=" + CustomTag)
End If
End If
End If
End If
Set PreviousAlbumsItem = lvAlbums.Interf.SelectedItem
Call SDB.ProcessMessages
LastSelection = " "
End Sub
Function CustomTag
CustomTag = lvCustom.Interf.SelectedItem.Tag
End Function
Function ArtistsTag
ArtistsTag = lvArtists.Interf.SelectedItem.Tag
End Function
Function AlbumsTag
AlbumsTag = lvAlbums.Interf.SelectedItem.Tag
End Function
Function CustomTextDQ
CustomTextDQ = DoubleUpSingleQuotes(lvCustom.Interf.SelectedItem.Text)
End Function
Function ArtistsTextDQ
ArtistsTextDQ = DoubleUpSingleQuotes(lvArtists.Interf.SelectedItem.Text)
End Function
Function AlbumsTextDQ
AlbumsTextDQ = DoubleUpSingleQuotes(lvAlbums.Interf.SelectedItem.Text)
End Function
Function AddItemsFromQuery(ListView, FullQuery)
AddItemsFromQuery = 0
Dim Iter : Set Iter = SDB.Database.OpenSQL(FullQuery)
Do While Not Iter.EOF
Call ListView.Interf.ListItems.Add(, , Cond(Iter.StringByIndex(0) <> "", Iter.StringByIndex(0), "<< Empty >>"))
ListView.Interf.ListItems(AddItemsFromQuery + 2).Tag = Iter.StringByIndex(1)
Iter.Next
AddItemsFromQuery = AddItemsFromQuery + 1
Loop
End Function
Sub AddTracksFromQueryAdvanced(FullQuery)
Call SDB.MainTracksWindow.AddTracksFromQuery("AND Songs.ID IN (" & FullQuery & ")")
End Sub
Sub FilllvCustom
Dim RecordCount
If CustomPaneKind = "Genres" Then
RecordCount = AddItemsFromQuery(lvCustom, "" _
+ "SELECT DISTINCTROW Genres.GenreName, Genres.IDGenre " _
+ "FROM Songs INNER JOIN Genres ON Songs.Genre = Genres.IDGenre " _
+ "ORDER BY GenreName")
Else
RecordCount = AddItemsFromQuery(lvCustom, "" _
+ "SELECT Lists.TextData, Lists.ID " _
+ "FROM Lists " _
+ "WHERE Lists.IDListType=" & GetIDListType(CustomPaneKind) & " " _
+ "ORDER BY Lists.TextData")
End If
lvCustom.Interf.ListItems(1).Text = "<< All (" & RecordCount & ") >>"
'Call lvArtists.Interf.ListItems.Clear
'Call lvAlbums.Interf.ListItems.Clear
Call SDB.ProcessMessages
End Sub
Function GetIDListType(Kind)
Select Case Kind
Case "Tempo": GetIDListType = 1
Case "Mood": GetIDListType = 2
Case "Occasion": GetIDListType = 3
Case "Quality": GetIDListType = 4
End Select
End Function
Sub DeselectListViews
If Not lvArtists.Interf.SelectedItem Is Nothing Then
lvArtists.Interf.SelectedItem.Selected = False
End If
If Not lvAlbums.Interf.SelectedItem Is Nothing Then
lvAlbums.Interf.SelectedItem.Selected = False
End If
End Sub
'*****************************************************
'**** GENERAL UTILITY METHODS ****
'*****************************************************
Function EqualNodes(Node1, Node2)
EqualNodes = False
If Not Node1 Is Nothing Then
If Not Node2 Is Nothing Then
If Node1.NodeType = Node2.NodeType Then
If Node1.Caption = Node2.Caption Then
EqualNodes = True
End If
End If
End If
End If
End Function
Function Cond(Test, ResultTrue, ResultFalse)
If Test Then
Cond = ResultTrue
Else
Cond = ResultFalse
End If
End Function
Function DoubleUpSingleQuotes(strInput)
DoubleUpSingleQuotes = Replace(strInput, "'", "''")
End Function
'*****************************************************
'**** CONTROLS UTILITY METHODS ****
'*****************************************************
' Most methods are taken from "Utility_Controls.vbs" (see Utility Scripts on http://www.mediamonkey.com/forum/viewtopic.php?t=7980)
' DropDown Style constants
Const csDropDown = 0 'DropDown can be edited
Const csDropDownList = 2 'DropDown cannot be edited (user can only select from a list of values)
Function CreateLabel(Owner, Caption, X, Y, Width, Height)
Set CreateLabel = SDB.UI.NewLabel(Owner)
CreateLabel.Caption = Caption
CreateLabel.Common.SetRect X, Y, Width, Height
End Function
Function CreateCheckBox(Owner, Caption, X, Y, Width, Height, ControlName)
Set CreateCheckBox = SDB.UI.NewCheckBox(Owner)
CreateCheckBox.Caption = Caption
CreateCheckBox.Common.SetRect X, Y, Width, Height
CreateCheckBox.Common.ControlName = ControlName
End Function
Function CreateEdit(Owner, Text, X, Y, Width, Height, ControlName)
Set CreateEdit = SDB.UI.NewEdit(Owner)
CreateEdit.Text = Text
CreateEdit.Common.SetRect X, Y, Width, Height
CreateEdit.Common.ControlName = ControlName
End Function
Function CreateButton(Owner, Caption, X, Y, Width, Height, OnClickHandler)
Set CreateButton = SDB.UI.NewButton(Owner)
CreateButton.Caption = Caption
CreateButton.Common.SetRect X, Y, Width, Height
If OnClickHandler <> "" Then
Script.RegisterEvent CreateButton.Common, "OnClick", OnClickHandler
End If
End Function
Function CreateDropDown(Owner, X, Y, Width, Height, ControlName)
Set CreateDropDown = SDB.UI.NewDropDown(Owner)
CreateDropDown.Common.SetRect X, Y, Width, Height
CreateDropDown.Common.ControlName = ControlName
End Function
Sub FillDropDownFromArray(DropDown, SourceArray)
Dim i
For i = 0 To UBound(SourceArray)
DropDown.AddItem SourceArray(i)
Next
End Sub
Sub SelectDropDownText(DropDown, Text)
Dim i
For i = 0 To DropDown.ItemCount - 1
If DropDown.ItemText(i) = Text Then
DropDown.ItemIndex = i
DropDown.Text = Text
Exit For
End If
Next
End Sub
Sub ClearDropDown(DropDown)
Dim i
For i = DropDown.ItemCount - 1 To 0 Step -1
DropDown.DeleteItem i
Next
DropDown.Text = ""
End Sub
In-depth information:
The script uses configuration entries in MediaMonkey's ini file.
(normally under folder My Documents\My Music\MediaMonkey)
The colors of the ListViews can be set at the beginning of the script as hex values:
Code: Select all
Const ForegroundColor = &H000000
Const BackgroundColor = &HEFEFEF
Don't worry. This is a preview version. More features will come, including an option panel.
You need MM 2.5.3 RC4 or newer to be able to run the script without problems.