Announcement

Collapse
No announcement yet.

Play bookmark???

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Play bookmark???

    How do you play a bookmark from a script?

    Thanks
    Last edited by mkronmal; January 14, 2007, 12:30 AM.

    #2
    Originally posted by mkronmal View Post
    How do you play a bookmark from a script?

    Thanks
    mkronmal,
    Direct playing of bookmarks is currently not implemented. Instead, you can grab the bookmarks into an array and parse it into locations and names, then play it based on it's position in the bookmarks. This can easily be adapted to play a bookmark based on it's name by iterating the names array and find the matching location. Here is the script that I came up with just now, commented and all:

    Code:
    Option Explicit
    
    Public SeerAMP
    Public myInst
    
    ' Setup a variable to call SeerAMP easily.
    Set SeerAMP = hs.Plugin("SeerAMP")
    ' Grab the instance number from it's name.
    myInst = SeerAMP.GetInstance("Bedroom")
    
    Sub Main()
    	' Declare our variables.
    	Dim strBookmarks
    	Dim strLocations
    	Dim strNames
    	Dim i
    
    	' This will grab the bookmarks and split them into an array.
    	' Even lines are the locations (filename, URL, etc).
    	' Odd lines are the names.
    	strBookmarks = Split(SeerAMP.GetBookmarks(myInst), vbCrLf)
    
    	' Here we will split the locations and names up into their
    	'	own arrays for ease of use.
    	For i = LBound(strBookmarks) To UBound(strBookmarks) Step 2
    		' If the current item doesn't have a matching name (the index after it)
    		'	then exit the for loop.
    		If (i + 1 > UBound(strBookmarks)) Then
    			Exit For
    		End If
    
    		' Put the current location into a string.
    		strLocations = strLocations & strBookmarks(i) & vbCrLf
    		' Put the current name into a string.
    		strNames = strNames & strBookmarks(i + 1) & vbCrLf
    	Next
    
    	' Split the locations up into an array.
    	strLocations = Split(strLocations, vbCrLf)
    	' Split the names up into an array.
    	strNames = Split(strNames, vbCrLf)
    
    	' Tell Winamp to stop playing.
    	Call SeerAMP.WAStop(myInst)
    
    	' Clear the playlist for our instance.
    	Call SeerAMP.ClearPlaylist(myInst)
    	' Wait 2 seconds to allow it to clear properly.
    	hs.WaitSecs 2
    
    	' Add the bookmark location of your choice (specified by the index, starting
    	'	at position 0) to the [now-empty] playlist.
    	Call SeerAMP.AddFile(myInst, strLocations(20))
    	' Wait another 2 seconds to make sure that the file gets added.
    	hs.WaitSecs 2
    
    	' Tell Winamp to play.
    	Call SeerAMP.Play(myInst)
    End Sub
    Last edited by dale3h; January 14, 2007, 05:31 PM.

    Comment

    Working...
    X