Sample Simple Tree Node script

From MediaMonkey Wiki
Revision as of 08:02, 21 August 2008 by Modementia (talk | contribs) (Removed additional While loop)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
' Sample Simple Tree Node script
'
' This script adds a new sub-node to Now Playing node. All tracks from Now Playing
' are present in the new node, but they are in reversed order.

Sub OnStartup
  Dim Tree
  Set Tree = SDB.MainTree

  Dim Node
  Set Node = Tree.CreateNode
  Node.Caption = "Reversed Now Playing"
  Node.IconIndex = 40
  Node.UseScript = Script.ScriptPath
  Node.OnFillTracksFunct = "FillNPTracks"

  Tree.AddNode Tree.Node_NowPlaying, Node, 3   ' Add as the last child
  Tree.Node_NowPlaying.Expanded = True
End Sub

Sub FillNPTracks( Node)
  Dim List, Trcks
  Set List = SDB.Player.CurrentPlaylist
  Set Trcks = SDB.MainTracksWindow

  Dim i
  i=0
  While i<List.Count And Not Script.Terminate
    Trcks.AddTrack List.Item(List.Count-i-1)
    i=i+1
  WEnd
  Trcks.FinishAdding
End Sub