Export M3U And Play In Winamp

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Export M3U And Play In Winamp

Post by Steegy » Tue Nov 22, 2005 6:01 am

Hello

I was in need of a script that could send any possible selection of tracks to Winamp (or another music program) fast.
Searching the forum I didn't found any script that could do that so I built my own.
It also contains code you can use to easily export a track selection list to a specified M3U file as playlist.

Hopefully some of you find this handy.

Cheers
Steegy

Code: Select all

'========================================================================== 
' 
' MediaMonkey Script 
' 
' NAME: ExportM3UAndPlayInWinamp v1.0 
' DESCRIPTION:
'  Exports selected tracks (tracks and full nodes) to a temporary M3U playlist
'   and then plays or enqueues that playlist in Winamp (or some other program).
'  It basically does the same thing as the SendToWinamp script but it also works
'   for larger selections (fixed Winamp crashing).
'
'  You can use the sub ExportM3U(mySongList, myExportPath) in your own scripts
'   since I haven't seen any such (useful) script on the forum that works.
'   Please mention where you got it from, if you use it.
'
'  Buttons are added for "Play in Winamp" and "Enqueue in Winamp" in the context menu's
'   (tracks, nodes, now playing) and to the standard toolbar.
' 
' AUTHOR: Steegy aka RC
' DATE  : 22.11.2005 
' 
' NOTE: Based on FurAnt's M3U Export script and Kyle White's SendToWinamp script.
'
'  By adding a file dialog, you can easily change this script to export the selected
'   tracks to a file that you specify using a "save as" dialog.
' 
' INSTALL: 
' - If wanted, change defaults in the "Variable Configuration" sections of this file
' - Copy script to MM directory scripts\auto 
' 
'========================================================================== 
Dim WinampEXE, tempM3UPath, lcPlayInWinamp, lcAddInWinamp, lcExportingToM3U, lcNothingToSend

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Variable Configuration: Change this if necessary
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
WinampEXE = Chr(34)&"c:\Program Files\Winamp\Winamp.exe"&Chr(34)
tempM3UPath = "c:\\mmExportM3UTemp.m3u"

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Variable Configuration: Localise this if necessary
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
' Dutch Localisation ;)
'lcPlayInWinamp = "Afspelen in Winamp"
'lcAddInWinamp = "Toevoegen in Winamp"
'lcExportingToM3U = "Exporteren naar M3U ..."
'lcNothingToSend = "Er is niets geselecteerd om naar Winamp te verzenden."

lcPlayInWinamp = "Play in Winamp"
lcAddInWinamp = "Enqueue in Winamp"
lcExportingToM3U = "Exporting to M3U file ..."
lcNothingToSend = "There are no songs to send."

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Here's the code
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Sub onStartUp 

   SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_TrackList,0,0

   Dim POPSWinamp 
   Set POPSWinamp = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList,0,0) 
   POPSWinamp.Caption = lcPlayInWinamp
   POPSWinamp.OnClickFunc = "kwPlayWinamp" 
   POPSWinamp.UseScript = Script.ScriptPath 
   POPSWinamp.IconIndex = 13 
    
   Dim POPSPreview 
   Set POPSPreview = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList,0,0) 
   POPSPreview.Caption = lcAddInWinamp
   POPSPreview.OnClickFunc = "kwEnqueueWinamp" 
   POPSPreview.UseScript = Script.ScriptPath 
   POPSPreview.IconIndex = 24 
    

   SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_NP,0,0

   Dim POPSWinamp2 
   Set POPSWinamp2 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP,0,0) 
   POPSWinamp2.Caption = lcPlayInWinamp
   POPSWinamp2.OnClickFunc = "kwPlayWinamp" 
   POPSWinamp2.UseScript = Script.ScriptPath 
   POPSWinamp2.IconIndex = 13 
    
   Dim POPSPreview2 
   Set POPSPreview2 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP,0,0) 
   POPSPreview2.Caption = lcAddInWinamp
   POPSPreview2.OnClickFunc = "kwEnqueueWinamp" 
   POPSPreview2.UseScript = Script.ScriptPath 
   POPSPreview2.IconIndex = 24 


   SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_Tree,0,0

   Dim POPSWinamp3 
   Set POPSWinamp3 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,0,0) 
   POPSWinamp3.Caption = lcPlayInWinamp
   POPSWinamp3.OnClickFunc = "kwPlayWinamp" 
   POPSWinamp3.UseScript = Script.ScriptPath 
   POPSWinamp3.IconIndex = 13 
    
   Dim POPSPreview3 
   Set POPSPreview3 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,0,0) 
   POPSPreview3.Caption = lcAddInWinamp
   POPSPreview3.OnClickFunc = "kwEnqueueWinamp" 
   POPSPreview3.UseScript = Script.ScriptPath 
   POPSPreview3.IconIndex = 24 


   SDB.UI.AddMenuItemSep SDB.UI.Menu_TbStandard,0,0

   Dim POPSWinamp4 
   Set POPSWinamp4 = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0) 
   POPSWinamp4.Caption = lcPlayInWinamp 
   POPSWinamp4.OnClickFunc = "kwPlayWinamp" 
   POPSWinamp4.UseScript = Script.ScriptPath 
   POPSWinamp4.IconIndex = 13 
    
   Dim POPSPreview4 
   Set POPSPreview4 = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0) 
   POPSPreview4.Caption = lcAddInWinamp
   POPSPreview4.OnClickFunc = "kwEnqueueWinamp" 
   POPSPreview4.UseScript = Script.ScriptPath 
   POPSPreview4.IconIndex = 24 

End Sub 



Sub ExportM3U(mySongList, myExportPath)

  Dim fOut
  Set fOut = SDB.Tools.FileSystem.CreateTextFile(myExportPath, True) 

  fOut.WriteLine "#EXTM3U"

  Dim Progress
  Set Progress = SDB.Progress 
  Progress.Text = lcExportingToM3U 

  Progress.MaxValue = mySongList.count 
  Dim i, mySong, mySongLength 
 
  For i=0 to mySongList.count-1 
    Set mySong = mySongList.Item(i) 
  
    mySongLength = mySong.SongLength 
    if mySongLength > 0 then 
      mySongLength = CStr(Round(mySongLength/1000)) 
    else 
      mySongLength = "" 
    end if 

    fOut.WriteLine "#EXTINF:" & mySongLength & "," & mySong.ArtistName & " - " & mySong.Title 
    fOut.WriteLine mySong.Path 

    Progress.Value = i+1 
  Next

  fOut.Close 
  Set Progress = Nothing 

End Sub 





Sub kwPlayWinamp(arg) 
   kwRunCommand("") 
End Sub 

Sub kwEnqueueWinamp(arg) 
  kwRunCommand("/ADD") 
End Sub 



Function kwRunCommand(inCommand) 

   Dim WShell, Result, Command, list

   Set list = SDB.SelectedSongList 
   If list.count = 0 Then 
      Set list = SDB.AllVisibleSongList 
      If list.count = 0 Then 
         Result = SDB.MessageBox(lcNothingToSend, mtError, Array(mbOK)) 
         Exit Function 
      End If 
   End If 

  ExportM3U list, tempM3UPath
  Command = WinampEXE & " " & inCommand & " " & tempM3UPath

  Set WShell = CreateObject("WScript.Shell") 
  Result = WShell.Run(Command, 0, 0)

End Function 

zverek
Posts: 6
Joined: Mon May 01, 2006 6:20 am

Post by zverek » Tue May 02, 2006 5:39 am

How to make this script replace Now Playing whith selected tracks?

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Tue May 02, 2006 6:39 am

Sorry, I don't understand what you mean.

The script lets you play/enqueue the selected MM songs in Winamp, from 4 different locations: Tracklist, Tree, Now Playing, Standard toolbar.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

zverek
Posts: 6
Joined: Mon May 01, 2006 6:20 am

Post by zverek » Wed May 03, 2006 2:01 pm

Select tracks -> Right click -> "Play in Winamp":
1. Places the selected tracks in Winamp
2. Places the selected tracks in Now Playing

And btw.. is there the context menu items in context menu in Now Plaing tracklist?

---
Sorry. I'm not very good in english.

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Wed May 03, 2006 4:00 pm

What you want can be done with:
Select tracks -> Right click -> "Play in Winamp"
Select tracks -> Right click -> "Play next" (or something similar: Alt+Enter, Shift+Enter, Shift+Ctrl+Enter)

I think combining these two things in the above script is a bit out of the scripts purpose scope. Because the behaviour (quite personal in this case, really) can be done manually very easily.

---
Me neither. What language do you normally speak?
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Iggy64
Posts: 117
Joined: Tue Feb 13, 2007 1:54 pm
Location: Ohio, USA

Re: Export M3U And Play In Winamp

Post by Iggy64 » Mon Mar 09, 2009 12:08 pm

I hope it is OK to revive this old thread.

I see that MM 3 has built in the ability to play tracks in Winamp (as opposed to the MM player).

I love MM as a library organizer --- it is the best thing ever, in that regard. Magic Nodes provide power that no one else can match. But I very much like using XMPlay as my player (sounds great, very easy on computer resources). It would be great to organize everything in MM, then play in XMPlay. It looks like Steegy wrote a script a few years ago that would send tracks to Winamp "or any other player." I guess I can just export playlists and import into XMPlay, but it would be very nice to have a simpler connection.

Would using Steegy's script still be the best way to work within the MM library, but play tracks in XMPlay?

If so, how do I install/implement the script? (I am a real newbie when it comes to scripts.)

Or is there some better approach available today?

Thanks!

Iggy64
Posts: 117
Joined: Tue Feb 13, 2007 1:54 pm
Location: Ohio, USA

Re: Export M3U And Play In Winamp

Post by Iggy64 » Tue Jan 18, 2011 7:35 pm

Now that a couple of years have gone by, I'd still like to find the answer. I hope someone can help me modify the ExportM3UandPlayinWinamp script so that I can play in XMPlay instead.

I tried modifying just the portion of the script marked "Variable Configuration: Change this if necessary." I changed the path to the location of XMPlay.exe. I also changed other text to "Play in XMPlay" and "Enqueue in XMPlay."

Now, the context menu for selected tracks shows me "Play in XMPlay" and "Enqueue in XMPlay." If I click one of these options, XMPlay is launched, but no tracks appear in XMPlay.

Subsequently, I revised the script further. I replaced all instances of "Winamp" with "XMPlay." This gave the same result as above. So I can get the script to launch XMPlay, but not load the selected files into XMPlay. I'll bet someone out there can tell me what I am doing wrong ( or - at least - the correct way to play in XMPlay).

Thanks, in advance, for any help you can offer.

Post Reply