Page 1 of 2

Enqueue Albums 1.3 - Updated 01/05/2010

Posted: Tue Jun 05, 2007 10:32 am
by trixmoto
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

Posted: Tue Jun 05, 2007 11:26 am
by MarineBrat
Seems to work nicely here on MM3A4.

Posted: Wed Jun 06, 2007 1:21 am
by powerpill-pacman
Works like a charm, now MM seems pretty much complete to me. Thanks very much for just another great script.

Posted: Fri Jun 08, 2007 7:03 am
by powerpill-pacman
Just one litlle wish to add: Would it be possible to create a new playlist from the enqueued albums autmatically?

Posted: Fri Jun 08, 2007 8:11 am
by trixmoto
I was about to say no, but I think I might just have worked out how to do it...

Posted: Fri Jun 08, 2007 8:55 am
by powerpill-pacman
Sounds good! :P

Posted: Fri Jun 08, 2007 9:12 am
by trixmoto
New version (1.1) is now available from my website (and code updated above). I have added the option to create playlists of the enqueued tracks.

Posted: Fri Jun 08, 2007 9:32 am
by powerpill-pacman
You're unbelievably fast. Thanks very much. But where can i find the playlist option?

Posted: Fri Jun 08, 2007 5:19 pm
by trixmoto
You have to edit the script file (look for the star (*)) by setting the "Playlists" variable to "True".

Posted: Sat Jun 09, 2007 12:41 pm
by powerpill-pacman
Thanks for the hint. I should've read the script (shame on me).

Re: Enqueue Albums 1.1 [MM2+3]

Posted: Mon Jun 29, 2009 1:04 am
by Juraitwaluzka
Very useful script. I was wondering how hard it would be to make it enqueue in such a way that the album plays next instead of at the end of the playlist.

An example... I have some auto playlists that generate say 2 hours of different songs. While listening I decide I want to hear the rest of the album of whatever song is playing. Now I do an 'Enqueue Albums' then manually move the tracks into place. However, it would be nice if the tracks would be inserted so that I automatically hear them next, then when the album runs out the rest of the playlist goes ahead.

Re: Enqueue Albums 1.1 [MM2+3]

Posted: Mon Jun 29, 2009 3:42 am
by trixmoto
It should be possible to do this, yes. I'll add it to my list.

Re: Enqueue Albums 1.2 - Updated 10/01/2010

Posted: Sun Jan 10, 2010 1:57 pm
by trixmoto
New version (1.2) is now available to download from my website. Changes include...

- Removed old MM2 code to improve performance
- Added option to play next instead of play last
- Added update server to installation package

Re: Enqueue Albums 1.2 - Updated 10/01/2010

Posted: Thu Jan 14, 2010 1:11 pm
by florin
Can you add an Enqueue Track option? It's the one option I would really like in MM.

Re: Enqueue Albums 1.2 - Updated 10/01/2010

Posted: Thu Jan 14, 2010 1:38 pm
by trixmoto
There are buttons on the toolbar for that, "Play Next" and "Play Last".