Code: Select all
'SendToWinamp for MediaMonkey - Created by W. Kyle White 4/30/05
'To install this script simply put it into the "scripts\auto" subdirectory of MediaMonkey
'When you next start MediaMonkey you will be able to right click on the Track List or the Playlist and
'select "Play in Winamp" or "Enqueue in Winamp" for the selected songs
'If no song is selected then the entire list will be played/enqueued
'This script may require modification if winamp is not in it's default directory
'If path names are VERY long (> 1000 characters at least) then this program may not function due to
'limitations on the length of commands being sent via the shell
'
'
'Rights & Regards:
'Script adapted from original Song Monitor/Previewer DJ Tool script by peke:
'http://www.mediamonkey.com/forum/viewtopic.php?t=2432
'Idea from howi: http://www.mediamonkey.com/forum/viewtopic.php?t=2712
'This script is free for any form of personal use or modification
'Use at your own risk, this script has not been throughly debugged
'The author takes no responsibility for any harm or loss of data caused by this script
WinampEXE = Chr(34)&"c:\Program Files\Winamp\Winamp.exe"&Chr(34)
MaxCommandLength = 1000
Sub onStartUp
' This places commands in the tracklist context menu
Dim POPSWinamp
Set POPSWinamp = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList,0,-3)
POPSWinamp.Caption = "Play in Winamp"
POPSWinamp.OnClickFunc = "kwPlayWinamp"
POPSWinamp.UseScript = Script.ScriptPath
POPSWinamp.IconIndex = 14
Dim POPSPreview
Set POPSPreview = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList,0,-3)
POPSPreview.Caption = "Enqueue in Winamp"
POPSPreview.OnClickFunc = "kwEnqueueWinamp"
POPSPreview.UseScript = Script.ScriptPath
POPSPreview.IconIndex = 16
' This places commands in the playlist context menu
Dim POPSWinamp2
Set POPSWinamp2 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP,0,-3)
POPSWinamp2.Caption = "Play in Winamp"
POPSWinamp2.OnClickFunc = "kwPlayWinamp"
POPSWinamp2.UseScript = Script.ScriptPath
POPSWinamp2.IconIndex = 14
Dim POPSPreview2
Set POPSPreview2 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP,0,-3)
POPSPreview2.Caption = "Enqueue in Winamp"
POPSPreview2.OnClickFunc = "kwEnqueueWinamp"
POPSPreview2.UseScript = Script.ScriptPath
POPSPreview2.IconIndex = 16
End Sub
Sub kwPlayWinamp(arg)
kwRunCommand("")
End Sub
Sub kwEnqueueWinamp(arg)
kwRunCommand("/ADD")
End Sub
Function kwRunCommand(inCommand)
Dim WShell, Result, Command, Song, Path, list, i
Set list = SDB.SelectedSongList
If list.count = 0 Then
Set list = SDB.AllVisibleSongList
If list.count = 0 Then
Result = SDB.MessageBox("There are no songs to send.", mtError, Array(mbOK))
Exit Function
End If
End If
Set WShell = CreateObject("WScript.Shell")
Command = WinampEXE&" "&inCommand
For i=0 To list.count-1
Set Song = list.item(i)
If (Song.Cached = 1) Then
Path = Chr(34)&Song.CachedPath&Chr(34)
ElseIf Not(Left(Song.Path,1) = "?") Then
Path = Chr(34)&Song.Path&Chr(34)
Else
Path = ""
Result = SDB.MessageBox( Song.Title&" is not available... Continue?", mtConfirmation, Array(mbYes, mbNo))
If (Result = mrNo) Then
Exit Function
End If
End If
If (len(Command) + len(Path) > MaxCommandLength) Then
'Debugging: Uncomment the next part to read and confirm the commands being sent to winamp
' Result = SDB.MessageBox("Sending command: "&Command, mtConfirmation, Array(mbYes, mbNo))
' If (Result = mrNo) Then
' Exit Function
' Else
Result = WShell.Run(Command, 1, 1)
' End If
' Flush the command and start up again with a command to enqueue the next songs
Command = WinampEXE&" /ADD"
End If
Command = Command&" "&Path
Next
End Function
btw, I'm more of a C++/Java guy, I'm kinda just throwing this together so feel free to comment/modify.[/code]