Bookmarker 2.0 - Updated 20/04/2010

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Bookmarker 2.0 - Updated 20/04/2010

Post by trixmoto » Sat Jan 21, 2006 12: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 4:35 pm, edited 3 times in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex » Sat Jan 21, 2006 12:19 pm

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

/Bex

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex » Sat Jan 21, 2006 12:30 pm

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

Good one trixi!

/Bex

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Sun Jan 22, 2006 11:01 am

Yeah sorry, the current version only supports a single bookmark. Is there demand for mutiple bookmarks?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex » Sun Jan 22, 2006 11:07 am

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

nachtgieger
Posts: 32
Joined: Thu Dec 19, 2002 3:41 am
Location: Germany

Post by nachtgieger » Mon Jan 23, 2006 5: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

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Jan 30, 2006 6: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 4:35 pm, edited 1 time in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

cadmanmeg
Posts: 309
Joined: Sun Nov 19, 2006 5:28 am

Post by cadmanmeg » Mon Apr 16, 2007 12:57 am

****after re-reading what was posted here before, I have answered my own questions****

darchangel
Posts: 26
Joined: Wed Nov 30, 2005 11:23 pm

Post by darchangel » Thu Jun 07, 2007 8:38 pm

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.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Fri Jun 08, 2007 3: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...".
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

darchangel
Posts: 26
Joined: Wed Nov 30, 2005 11:23 pm

Post by darchangel » Fri Jun 08, 2007 7:05 am

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

GargantulaKon
Posts: 155
Joined: Sat Oct 06, 2007 1:54 pm

Post by GargantulaKon » Tue Jan 01, 2008 5: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.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Jan 02, 2008 4: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.?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

GargantulaKon
Posts: 155
Joined: Sat Oct 06, 2007 1:54 pm

Post by GargantulaKon » Sat Jan 05, 2008 5: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.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Tue Jan 22, 2008 4:37 pm

New version (1.2) is now available to download from my website. I have now resolved the MM3 compatibility issues. :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Post Reply