Enqueue Albums 1.3 - Updated 01/05/2010
Posted: Tue Jun 05, 2007 10:32 am
This script was requested here. It loops through the selected tracks, adding all the tracks in the album of each one to the end of the Now Playing list. An option appears in the context menu (tracklist and now playing) to trigger this script.
Code: Select all
'
' MediaMonkey Script
'
' NAME: EnqueueAlbums 1.3
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 01/05/2010
'
' Thanks to Steegy for the SkinnedInputBox
'
' INSTALL: Copy to Scripts\Auto directory
'
' FIXES: Fixed tracks not being added in correct order
'
Option Explicit
Dim Playlists : Playlists = False
Dim PlayNext : PlayNext = False
Sub onStartUp
Dim itm : Set itm = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP,1,1)
itm.Caption = "Enqueue Albums"
itm.OnClickFunc = "ItmClick"
itm.UseScript = Script.ScriptPath
itm.IconIndex = 56
Set SDB.Objects("EnqueueAlbumsMenu1") = itm
Set itm = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList,1,1)
itm.Caption = "Enqueue Albums"
itm.OnClickFunc = "ItmClick"
itm.UseScript = Script.ScriptPath
itm.IconIndex = 56
Set SDB.Objects("EnqueueAlbumsMenu2") = itm
End Sub
Sub ItmClick(itm)
Dim list : Set list = SDB.SelectedSongList.Albums
If list.Count > 0 Then
Dim p : Set p = Nothing
If Playlists Then
Dim n : n = SkinnedInputBox("Please enter unique playlist name:","EnqueueAlbums","","EnqueueAlbumsPosition")
If Not (n = "") Then
Set p = SDB.PlaylistByTitle("").CreateChildPlaylist(n)
End If
End If
Dim i : i = 0
Dim k : k = SDB.Player.CurrentSongIndex
For i = 0 To list.Count-1
Dim j : j = 0
Dim sql : sql = "AND Songs.IDAlbum="&list.Item(i).ID&" ORDER BY DiscNumber COLLATE NUMERICSTRING,TrackNumber COLLATE NUMERICSTRING"
Dim itr : Set itr = SDB.Database.QuerySongs(sql)
While Not itr.EOF
j = j+1
Dim t : Set t = itr.Item
Call SDB.Player.PlaylistAddTrack(t)
If PlayNext Then
Call SDB.Player.PlaylistMoveTrack(SDB.Player.PlaylistCount-1,k+((i+1)*j))
End If
If Not (p Is Nothing) Then
Call p.AddTrack(t)
End If
itr.Next
WEnd
Next
End If
End Sub
Function SkinnedInputBox(Text, Caption, Input, PositionName)
Dim Form, Label, Edt, btnOk, btnCancel, modalResult
' Create the window to be shown
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 360, 130
Form.BorderStyle = 2 ' Resizable
Form.FormPosition = 4 ' Screen Center
Form.SavePositionName = PositionName
Form.Caption = Caption
' Create a button that closes the window
Set Label = SDB.UI.NewLabel(Form)
Label.Caption = Text
Label.Common.Left = 5
Label.Common.Top = 10
Set Edt = SDB.UI.NewEdit(Form)
Edt.Common.Left = Label.Common.Left
Edt.Common.Top = Label.Common.Top + Label.Common.Height + 5
Edt.Common.Width = Form.Common.Width - 20
Edt.Common.ControlName = "Edit1"
Edt.Common.Anchors = 1+2+4 'Left+Top+Right
Edt.Text = Input
' Create a button that closes the window
Set BtnOk = SDB.UI.NewButton(Form)
BtnOk.Caption = "&OK"
BtnOk.Common.Top = Edt.Common.Top + Edt.Common.Height + 10
BtnOk.Common.Hint = "OK"
BtnOk.Common.Anchors = 4 ' Right
BtnOk.UseScript = Script.ScriptPath
BtnOk.Default = True
BtnOk.ModalResult = 1
Set BtnCancel = SDB.UI.NewButton(Form)
BtnCancel.Caption = "&Cancel"
BtnCancel.Common.Left = Form.Common.Width - BtnCancel.Common.Width - 15
BtnOK.Common.Left = BtnCancel.Common.Left - BtnOK.Common.Width - 10
BtnCancel.Common.Top = BtnOK.Common.Top
BtnCancel.Common.Hint = "Cancel"
BtnCancel.Common.Anchors = 4 ' Right
BtnCancel.UseScript = Script.ScriptPath
BtnCancel.Cancel = True
BtnCancel.ModalResult = 2
If Form.showModal = 1 Then
SkinnedInputBox = Edt.Text
Else
SkinnedInputBox = ""
End If
End Function