Bookmarker 2.0 - Updated 20/04/2010

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Bookmarker 2.0 - Updated 20/04/2010

Postby trixmoto on Sat Jan 21, 2006 5:13 pm

As requested, this script creates a new node in the tree which allows you to store unlimited bookmarks. The current track and position are stored and can they be restarted at any point. If the track is in the Now Playing list it will be used, otherwise it will be added to the end when you play it. You can right click on the bookmark node to rename or remove the bookmark (note that the bookmarked track will not be removed, only the bookmark itself).

Image

As always the installer can be downloaded from my website, and the code is below...

Code: Select all
'
' MediaMonkey Script
'
' NAME: Bookmarker 2.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 20/04/2010
'

Option Explicit

Sub OnStartup()
  Dim ini : Set ini = SDB.IniFile
  Dim ind : ind = 0
  If ini.ValueExists("Bookmarker","Index") Then
    ind = ini.IntValue("Bookmarker","Index")
  Else
    ini.IntValue("Bookmarker","Index") = 0
  End If   
 
  'create tree
  Dim tree : Set tree = SDB.MainTree
  Dim root : Set root = SDB.Objects("BookmarkerRoot")
  If Not (root Is Nothing) Then
    Call tree.RemoveNode(root)
  End If     
  Set root = tree.CreateNode
  root.Caption = "Bookmarks"
  root.IconIndex = 19
  root.UseScript = Script.ScriptPath
  root.OnFillChildren = "FillBookmarks"
  Call tree.AddNode(tree.Node_Library,root,1) 'add after library
  root.HasChildren = True
  Set SDB.Objects("BookmarkerRoot") = root
End Sub

Sub FillBookmarks(root)
  root.HasChildren = False

  Dim tree : Set tree = SDB.MainTree
  Dim node : Set node = tree.CreateNode
  node.Caption = "Add new..."
  node.IconIndex = 6
  node.UseScript = Script.ScriptPath
  node.OnFillChildren = "FillAddNew"
  Call tree.AddNode(root,node,2) 'add child of bookmarks
  node.HasChildren = True
 
  Dim ini : Set ini = SDB.IniFile 
  Dim keys : Set keys = ini.Keys("Bookmarker")
  Dim i : i = 0
  For i = 0 To keys.Count-1
    Dim k : k = keys.Item(i)
    If Left(k,1) = "#" Then
      Dim j : j = InStr(k,"=")
      Dim bid : bid = Mid(k,2,j-2)
      Dim cap : cap = Mid(k,j+1)     
      Dim a : a = Split(ini.StringValue("Bookmarker","@"&bid)," ")
      Set node = tree.CreateNode
      node.Caption = cap
      node.CustomNodeId = bid
      node.CustomDataId = a(0) 'songs.id       
      node.CustomData = a(1) 'position       
      node.IconIndex = 3
      Call tree.AddNode(root,node,3) 'add child of bookmarks
      Call Script.RegisterEvent(node,"OnFillChildren","FillChildren")
      Call Script.RegisterEvent(node,"OnFillTracks","FillTracks")
      Call Script.RegisterEvent(node,"OnCanEditNode","EditNode")
      Call Script.RegisterEvent(node,"OnNodeEditText","OrigName")
      Call Script.RegisterEvent(node,"OnNodeEdited","EditName")
      Call Script.RegisterEvent(node,"OnShowMenuItem","ShowMenu")
      Call Script.RegisterEvent(node,"OnExecMenuItem","ExecMenu")       
      node.HasChildren = True
    End If
  Next
     
  root.HasChildren = True
End Sub

Sub FillAddNew(node)
  node.HasChildren = False
 
  'initialise
  Dim root : Set root = SDB.Objects("BookmarkerRoot")
  If root Is Nothing Then
    Call SDB.MessageBox("Bookmarker - root node is missing!",mtError,Array(mbOk))   
    Exit Sub 
  End If 
  Dim itm : Set itm = SDB.Player.CurrentSong
  If itm Is Nothing Then
    Call SDB.MessageBox("Bookmarker - there is no current song to bookmark!",mtError,Array(mbOk))   
    Exit Sub 
  End If 
  If (itm.ID < 1) Or (itm.IsntInDB) Then
    Call SDB.MessageBox("Bookmarker - song must be in the library to bookmark!",mtError,Array(mbOk))   
  End If
     
  'add to ini file
  Dim ini : Set ini = SDB.IniFile
  Dim ind : ind = ini.IntValue("Bookmarker","Index")+1
  Dim pbt : pbt = SDB.Player.PlaybackTime 
  Dim sid : sid = itm.ID
  Dim cap : cap = itm.Title&" ("&FormatTime(pbt)&")"
  ini.StringValue("Bookmarker","#"&ind) = cap
  ini.StringValue("Bookmarker","@"&ind) = sid&" "&pbt
  ini.IntValue("Bookmarker","Index") = ind
 
  'create node
  Dim tree : Set tree = SDB.MainTree
  Dim subn : Set subn = tree.CreateNode
  subn.Caption = cap
  subn.CustomNodeId = ind
  subn.CustomDataId = sid 'songs.id               
  subn.CustomData = pbt 'position       
  subn.IconIndex = 3
  Call tree.AddNode(root,subn,3) 'add child of bookmarks
  Call Script.RegisterEvent(subn,"OnFillChildren","FillChildren")
  Call Script.RegisterEvent(subn,"OnFillTracks","FillTracks") 
  Call Script.RegisterEvent(subn,"OnCanEditNode","EditNode")
  Call Script.RegisterEvent(subn,"OnNodeEditText","OrigName")
  Call Script.RegisterEvent(subn,"OnNodeEdited","EditName")
  Call Script.RegisterEvent(subn,"OnShowMenuItem","ShowMenu")
  Call Script.RegisterEvent(subn,"OnExecMenuItem","ExecMenu")         
  subn.HasChildren = True
       
  tree.CurrentNode = tree.Node_NowPlaying         
  node.HasChildren = True
End Sub

Sub FillChildren(node)
  node.HasChildren = False
 
  'find song in now playing
  Dim list : Set list = SDB.Player.CurrentSongList
  Dim add : add = True
  Dim sid : sid = node.CustomDataId
  Dim pbt : pbt = node.CustomData
  If SDB.Player.CurrentSong.ID = sid Then
    add = False
  Else
    Dim i : i = 0
    For i = 0 To list.Count-1
      Dim itm : Set itm = list.Item(i)
      If itm.ID = sid Then
        SDB.Player.CurrentSongIndex = CLng(i)
        add = False
        Exit For
      End If
    Next
  End If 
 
  'add song to now playing
  If add Then
    Dim iter : Set iter = SDB.Database.QuerySongs("AND (Songs.ID="&sid&")")
    If Not iter.EOF Then
      SDB.Player.PlaylistAddTrack(iter.item)
      SDB.Player.CurrentSongIndex = list.Count
    End If
    Set iter = Nothing
  End If
 
  'play song
  SDB.Player.Play
  While SDB.Player.IsStartingPlayback
    SDB.ProcessMessages
  WEnd 
  SDB.Player.PlaybackTime = pbt
 
  Dim tree : Set tree = SDB.MainTree
  tree.CurrentNode = tree.Node_NowPlaying
  node.HasChildren = True
End Sub

Sub FillTracks(node)
  node.HasChildren = False
   
  Dim main : Set main = SDB.MainTracksWindow
  main.AddTracksFromQuery("WHERE Songs.Id="&node.CustomDataId)
  main.FinishAdding 
 
  node.HasChildren = True 
End Sub

Function ShowMenu(mode)
  If mode = 5 Then
    ShowMenu = True
  Else
    ShowMenu = False
  End If   
End Function

Function ExecMenu(mode)
  If mode = 5 Then 
    Dim tree : Set tree = SDB.MainTree
    Dim node : Set node = tree.CurrentNode
    Dim ind : ind = node.CustomNodeId
    Call SDB.IniFile.DeleteKey("Bookmarker","#"&ind)
    Call SDB.IniFile.DeleteKey("Bookmarker","@"&ind)
    Call tree.RemoveNode(node)               
    ExecMenu = True
  Else 
    ExecMenu = False
  End If
End Function

Function EditNode(node)
  EditNode = True
End Function

Function OrigName(node)
  OrigName = SDB.IniFile.StringValue("Bookmarker","#"&node.CustomNodeId)
End Function   

Sub EditName(node,cap)
  SDB.IniFile.StringValue("Bookmarker","#"&node.CustomNodeId) = cap
  node.Caption = cap
End Sub

Function FormatTime(mil)
  Dim intLength : intLength = CCur(mil/1000)
  Dim datLength : datLength = TimeSerial(11,11,11)
  Dim strLength : strLength = FormatDateTime(datLength,vbshorttime)
  Dim strTimeSeparator : strTimeSeparator = Left(Replace(strLength,"1",""),1)
  Dim intLengthHeures : intLengthHeures = Int((intLength / 60) / 60)
  Dim intLengthMinutes : intLengthMinutes = Int((intLength / 60) Mod 60)
  Dim intLengthSecondes : intLengthSecondes = Int(intLength Mod 60)
  strLength = intLengthHeures&strTimeSeparator
  If intLengthMinutes < 10 Then
    strLength = strLength&"0"
  End If
  strLength = strLength&intLengthMinutes&strTimeSeparator
  If intLengthSecondes < 10 Then
    strLength = strLength&"0"
  End If
  FormatTime = strLength&intLengthSecondes
End Function
Last edited by trixmoto on Tue Jan 22, 2008 9:35 pm, edited 3 times in total.
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Getting "Product Installation Error" when installing scripts? - Try this
Subscribe to my RSS feed for all the latest news
trixmoto
 
Posts: 8509
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby Bex on Sat Jan 21, 2006 5:19 pm

Cool, i'll check it out! Does it handle multiple files? Meaning could I save bookmark for several files?

/Bex
Bex
 
Posts: 5924
Joined: Fri May 21, 2004 10:44 am
Location: Sweden

Postby Bex on Sat Jan 21, 2006 5:30 pm

Works perfectly! And of course it only handles one file.

Good one trixi!

/Bex
Bex
 
Posts: 5924
Joined: Fri May 21, 2004 10:44 am
Location: Sweden

Postby trixmoto on Sun Jan 22, 2006 4:01 pm

Yeah sorry, the current version only supports a single bookmark. Is there demand for mutiple bookmarks?
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Getting "Product Installation Error" when installing scripts? - Try this
Subscribe to my RSS feed for all the latest news
trixmoto
 
Posts: 8509
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby Bex on Sun Jan 22, 2006 4:07 pm

trixmoto wrote:Yeah sorry, the current version only supports a single bookmark. Is there demand for mutiple bookmarks?


No, bookmark one file at a time is enough for me!

/Bex
Bex
 
Posts: 5924
Joined: Fri May 21, 2004 10:44 am
Location: Sweden

Postby nachtgieger on Mon Jan 23, 2006 10:25 am

for multiple bookmarks try Christer Sundin's WinAmp plugin "Amarok", it works with MediaMonkey and saves bookmarks in a textfile per song. You can get it from http://www.sundin.nu/winamp/plugins.html
nachtgieger
 
Posts: 32
Joined: Thu Dec 19, 2002 8:41 am
Location: Germany

Postby trixmoto on Mon Jan 30, 2006 11:36 am

New version (1.1) now handles the situation where the track no longer exists in your library.

Code: Select all
New code above
Last edited by trixmoto on Tue Jan 22, 2008 9:35 pm, edited 1 time in total.
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Getting "Product Installation Error" when installing scripts? - Try this
Subscribe to my RSS feed for all the latest news
trixmoto
 
Posts: 8509
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby cadmanmeg on Mon Apr 16, 2007 5:57 am

****after re-reading what was posted here before, I have answered my own questions****
cadmanmeg
 
Posts: 305
Joined: Sun Nov 19, 2006 10:28 am

Postby darchangel on Fri Jun 08, 2007 1:38 am

I can't figure out the part about "set the order appropriately". What numbers do these indicate? And how do I use the script once I've gotten these set and the vbs saved in the Scripts folder? I can't get it to appear on any menu.
darchangel
 
Posts: 26
Joined: Thu Dec 01, 2005 4:23 am

Postby trixmoto on Fri Jun 08, 2007 8:47 am

The "Order" represents the position in the menu bar. After saving the ini section in your Scripts.ini file, the next time you start MM it should appear in "Tools, Scripts, Bookmarker...".
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Getting "Product Installation Error" when installing scripts? - Try this
Subscribe to my RSS feed for all the latest news
trixmoto
 
Posts: 8509
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby darchangel on Fri Jun 08, 2007 12:05 pm

Oh! the Scripts.ini. I'd kept trying to get to work by working with MediaMonkey.ini

Thank you so much. I was feeling like a dope
darchangel
 
Posts: 26
Joined: Thu Dec 01, 2005 4:23 am

Postby GargantulaKon on Tue Jan 01, 2008 10:20 pm

This topic title suggests that it works for MM3, but it does not seem to be the case when I check out your site. I tried it and it does not work for me.
MediaMonkey Gold (Lifetime)
- If my configuration's specifications are helpful, please go here.
GargantulaKon
 
Posts: 156
Joined: Sat Oct 06, 2007 6:54 pm

Postby trixmoto on Wed Jan 02, 2008 9:30 am

Yes, an issue was introduced during the MM3 RC versions so setting the playback time now doesn't work properly, it needs to be done via a timer. Isn't this functionality native though, or audiobooks and podcasts, etc.?
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Getting "Product Installation Error" when installing scripts? - Try this
Subscribe to my RSS feed for all the latest news
trixmoto
 
Posts: 8509
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby GargantulaKon on Sat Jan 05, 2008 10:38 pm

Yes, I think so, but I am not sure if it works for all of the files or in the non-Gold version. I got ResumePlay 2.0 to work for me though.
MediaMonkey Gold (Lifetime)
- If my configuration's specifications are helpful, please go here.
GargantulaKon
 
Posts: 156
Joined: Sat Oct 06, 2007 6:54 pm

Postby trixmoto on Tue Jan 22, 2008 9:37 pm

New version (1.2) is now available to download from my website. I have now resolved the MM3 compatibility issues. :)
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Getting "Product Installation Error" when installing scripts? - Try this
Subscribe to my RSS feed for all the latest news
trixmoto
 
Posts: 8509
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: Ask Jeeves [Bot], MSN [Bot] and 6 guests