[Script] Clear and Queue [MM2+3] [2008.06.22]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

[Script] Clear and Queue [MM2+3] [2008.06.22]

Postby Teknojnky » Sat Jun 21, 2008 3:35 pm

This script will clear the now playing list and queue the selected tracks without interupting the currently playing track.

If the player is not playing, it will clear, queue and start playing the selected tracks.

http://teknojnky.googlepages.com/ClearAndQueue.mmip

Should work on mm2 and mm3 but have not tested on mm2.

Code: Select all
Option Explicit
'==========================================================================
'
' MediaMonkey Script
'
' SCRIPTNAME: Clear and Queue
' DEVELOPMENT STARTED: 2008.06.21
  Dim Version : Version = "2008.06.22.1100"

' DESCRIPTION: Adds a context menu to clear the now playing and queue the selected
'       tracks without interupting the currently playing track'
' FORUM THREAD: http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=30535
'
' INSTALL:
' - download install package @ http://teknojnky.googlepages.com/ClearAndQueue.mmip

' Recent Updates:
' 2008.06.21 Initial version'


Sub OnStartup

  Do While Not SDB.IsRunning
    SDB.Tools.Sleep 100
    SDB.ProcessMessages
  Loop

  Dim mnu
  Set mnu = SDB.UI.AddMenuItem (SDB.UI.Menu_Pop_TrackList,2,0)
 
  mnu.Caption = "Clear and Queue Next"

  Script.RegisterEvent mnu, "OnClick", "ClearAndQueue"
  mnu.IconIndex = 54
  mnu.Hint = "Clears the Now Playing Window and queues selected files"
'   mnu.Shortcut = "" 'assign your own shortcut'

  Set mnu = SDB.UI.AddMenuItem (SDB.UI.Menu_Pop_NP,1,0)
  mnu.Caption = "Clear and Queue Next"

  Script.RegisterEvent mnu, "OnClick", "ClearAndQueue"
  mnu.IconIndex = 54
  mnu.Hint = "Clears the Now Playing Window and queues selected files"

  Set mnu = SDB.UI.AddMenuItem (SDB.UI.Menu_Pop_Tree,2,0)
  mnu.Caption = "Clear and Queue Next"

  Script.RegisterEvent mnu, "OnClick", "ClearAndQueue"
  mnu.IconIndex = 54
  mnu.Hint = "Clears the Now Playing Window and queues selected files"



End Sub


Sub ClearAndQueue(obj)

  Dim Selected
 
  Set Selected = SDB.CurrentSongList

  If Selected.Count > 0 Then
    SDB.Player.PlaylistClear
     
'     SDB.Player.PlaylistAddTrack(SDB.Player.CurrentSong)
    SDB.Player.PlaylistAddTracks(Selected)
    If SDB.Player.isPlaying = False Then SDB.Player.Play
  End If

End Sub
Last edited by Teknojnky on Mon Jun 23, 2008 12:08 pm, edited 2 times in total.
Teknojnky
 
Posts: 5521
Joined: Tue Sep 06, 2005 11:01 pm

Re: [Script] Clear and Queue [MM2+3] [2008.06.21]

Postby Squishy » Sat Jun 21, 2008 7:32 pm

Excellent script, just what I was looking for. I was wondering if it could be possible to add the same feature when right clicking in the nodes window.

Thanks
Squishy
 
Posts: 6
Joined: Sun Jun 01, 2008 8:26 pm

Re: [Script] Clear and Queue [MM2+3] [2008.06.21]

Postby nynaevelan » Sun Jun 22, 2008 7:58 pm

Technojunky:

I've finally gotten around to being able to test out the script. Would it be possible to leave the currently playing track in the Now Playing list? Although it does not interrupt the song, I would like it to still be available because I sometimes edit songs while they are playing when I discover discrepancies in the tags or I want to add notes/ratings regarding the track.

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: [Script] Clear and Queue [MM2+3] [2008.06.21]

Postby Teknojnky » Mon Jun 23, 2008 11:50 am

@ squishy, I have added the tree menu's, I missed those the first time.

@ nyn, I tried the below but it did not work as expected so I had removed it from the initial release. What happens is that current song is essentially removed from the list and then added back which ends up causing it to play twice.

Code: Select all
  If Selected.Count > 0 Then
    SDB.Player.PlaylistClear
    SDB.Player.PlaylistAddTrack(SDB.Player.CurrentSong)
    SDB.Player.PlaylistAddTracks(Selected)
    If SDB.Player.isPlaying = False Then SDB.Player.Play
  End If


Now I suppose I could loop thru the entire now playing list and remove each track individually instead of using player.playlistclear, but I figured that it would be very in-efficient and slow (especially on large now playing lists) so I didnt bother with it.

Not to mention a bit more complex due to having to account for deleting an unknown number of songs before and after the current track without deleting the current track.

Also, you do know you can right click the player and go to properties to access the track properties that is playing? Perhaps not as easy as using the detail grids, but...

I don't think I will make it part of the script, but if you really wanted to loop thru, I would guess it could work something like the below pseudocode (untested of course)

x=0
do while playlistcount > 1
if x <> currentsongindex then playlistdelete(x)
x=x+1
loop

or something along those lines.

if someone wants to figure it out, test it and post it, others could use it if they desire.

edit: actually I don't think the above will work, because x would be increasing but the index# and count would be changing as songs were removed.

edit2: perhaps something like this instead
do while playlistcount > 1
if currentsongindex <> 0 then
playlistdelete(0)
else
playlistdelete(1)
end if
loop

that might work
Last edited by Teknojnky on Mon Jun 23, 2008 12:03 pm, edited 1 time in total.
Teknojnky
 
Posts: 5521
Joined: Tue Sep 06, 2005 11:01 pm

Re: [Script] Clear and Queue [MM2+3] [2008.06.21]

Postby nynaevelan » Mon Jun 23, 2008 12:02 pm

Teknojnky wrote:Also, you do know you can right click the player and go to properties to access the track properties that is playing? Perhaps not as easy as using the detail grids, but...


This method would be fine with me, as long as I still have the "easy" access to get to the file I am content. I know there are some that would suggest the keyboard shortcuts but I don't use them and it is difficult to remember what all the different options are, I have to write down the three that I do use. I am a right-clicking kind of girl. :wink:


Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby nynaevelan » Tue Jun 24, 2008 4:43 pm

Tekno:

It's not a requirement, but is it possible for the script to be run when a playlist is selected without having to select all the tracks in the playlist?

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby Teknojnky » Tue Jun 24, 2008 5:45 pm

nynaevelan wrote:Tekno:

It's not a requirement, but is it possible for the script to be run when a playlist is selected without having to select all the tracks in the playlist?

Nyn


it should work (does for me) by simply right clicking the playlist in the tree, you don't need to have the individual files selected when using the tree context menu, all files will be added.
Teknojnky
 
Posts: 5521
Joined: Tue Sep 06, 2005 11:01 pm

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby nynaevelan » Tue Jun 24, 2008 5:57 pm

It's not working for me, am I missing sometihing??

Image

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby Teknojnky » Tue Jun 24, 2008 6:50 pm

do you have the 6/21 or 6/22 version?

the version linked and posted above should have the tree menu added (wasn't in the initial)
Teknojnky
 
Posts: 5521
Joined: Tue Sep 06, 2005 11:01 pm

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby nynaevelan » Tue Jun 24, 2008 7:18 pm

I think I must have been using the 6/21 version because once I updated I now have the script in the menu. Thank you for your help and the script, I am really starting to enjoy the convenience of it. :P

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby MM3 monkey » Sat Jan 17, 2009 6:19 am

Thanks, Teknojnky. I'm just about to install it for the first time. Thanks, Nyn for putting it in your sig.

Also In Nyn's signature is a script "Copy 2 Playlist". A google of [[ site:mediamonkey.com/forum intitle:copy intitle:playlist ]] didn't find it. I wonder what it is?
MM3 monkey
 
Posts: 445
Joined: Mon Aug 27, 2007 2:34 am

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby onenonymous » Sun Jan 25, 2009 1:40 pm

I use the code below in my ClearNowPlayingButton.vbs script. It does slow down if there are lots of files in Now Playing- but it does do the trick to remove before and after the currently playing song without removing it. Just call ClearBeforeAfterNP(o) rather than SDB.Player.PlaylistClear.

Code: Select all
Sub ClearBeforeNP(o)
   dim iSongItem, i
   iSongItem = CInt(SDB.Player.CurrentSongIndex)
   For i = 0 To iSongItem - 1
      SDB.Player.PlaylistDelete(0)
   Next
End Sub

Sub ClearAfterNP(o)
   dim iSongItem, i
   iSongItem = CInt(SDB.Player.CurrentSongIndex) + 1
   For i = iSongItem to SDB.Player.PlaylistCount
      SDB.Player.PlaylistDelete(iSongItem)
   Next
End Sub

Sub ClearBeforeAfterNP(o)
   Call ClearBeforeNP(o)
   Call ClearAfterNP(o)
End Sub
onenonymous
 
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby nynaevelan » Sun Jan 25, 2009 2:13 pm

MM3 monkey wrote:
Also In Nyn's signature is a script "Copy 2 Playlist". A google of [[ site:mediamonkey.com/forum intitle:copy intitle:playlist ]] didn't find it. I wonder what it is?


MM3:

This is a little one that Raybeau made for me in order to copy the now playing song to a particular playlist. You can find it by scrolling in the Stations topic, I think it is on page 2 or 3. I also use Onenonymous's Right Click for Scripts script in order to add a toolbar icon for it onto the Now Playing Main window, which makes it more accessible. THis script is quite handy because it allows me to save songs that I eventually want to add to a particular playlist but at the time I am too busy to work on it.

There is also another one he created in the same forum, this one will copy the entire now playing list to a particular playlist, there is one that is manual and one that can be setup to run automatically at a certain time. I use the manual one because I was getting too many with the automated one.

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby MM3 monkey » Sun Jan 25, 2009 4:05 pm

Thanks, Nyn.
MM3 monkey
 
Posts: 445
Joined: Mon Aug 27, 2007 2:34 am

Re: [Script] Clear and Queue [MM2+3] [2008.06.22]

Postby Guest » Sat Mar 21, 2009 9:43 pm

Thought I'd share a customization. This adds the current song list in random order (and does that quickly), and enables continuous playback. Someone could add switches to enable/disable these things. I'll do that myself if I ever find a need for disabling them.

Code: Select all
Sub ClearAndQueue(obj)

  Dim Selected
 
  Set Selected = SDB.CurrentSongList

  If Selected.Count > 0 Then
    Dim Randomized : Set Randomized = RandomizedSongList(Selected)
    SDB.Player.PlaylistClear
'     SDB.Player.PlaylistAddTrack(SDB.Player.CurrentSong)   
    SDB.Player.PlaylistAddTracks(Randomized)
    SDB.Player.isRepeat = True
    If SDB.Player.isPlaying = False Then SDB.Player.Play
  End If

End Sub

Function RandomizedSongList(f)
  Dim RndList : RndList = RandomList(f.Count)
  Dim t : Set t = SDB.NewSongList
  Dim i
  For i = 0 To f.Count - 1
   t.Add( f.Item( RndList(i) ) )
  Next
  Set RandomizedSongList = t
End Function

Function RandomList(size)
  Randomize
  ReDim list(size)
  Dim i
  For i = 0 To size - 1
    list(i) = i
  Next
  For i = 0 To size - 1
    Dim j : j = Int( (size - i + 1) * Rnd + i )
    Dim tmp : tmp = list(i)
    list(i) = list(j)
    list(j) = tmp
  Next
  RandomList = list
End Function
Guest
 

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: buetthead and 17 guests