Results 1 to 22 of 22

Thread: VB6 - Get Winamp 5.xx currently playing module.

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    VB6 - Get Winamp 5.xx currently playing module.

    Hi, in this thread i will show you how to get the currently playing winamp 5.xx series song, the original code was found by me, unworking, and abandoned, i have fixed this and made this work once again.
    Enjoy.

    VB Code:
    1. 'In a module
    2. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    3. 'API call to get the windows text, this is useful as WinAMP's
    4. 'currently playing song is a part of its title.
    5. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    6. Public lHandle As Long
    7. 'this API call finds the WinAmp window when the correct parameters
    8. 'are passed to it.
    9.  
    10. Function getWinampWindow()
    11. lHandle = FindWindow("Winamp v1.x", vbNullString) 'This is for finding the window, "Winamp v1.x" is the reference to the window type of the Winamp pogram
    12. If lHandle > 0 Then 'making sure the window exists
    13.     Dim lRet As Long
    14.     Dim sTitle As String * 256
    15.     Dim sCaption As String
    16.     lRet = GetWindowText(lHandle, sTitle, Len(sTitle))
    17.     sCaption = Left(sTitle, InStr(1, sTitle, vbNullChar, vbTextCompare) - 10)
    18.     Do
    19.         If IsNumeric(Left(sCaption, 1)) = True Or Left(sCaption, 1) = "." Or Left(sCaption, 1) = " " Then
    20.         sCaption = Right(sCaption, Len(sCaption) - 1)
    21.         Else
    22.         Exit Do
    23.         End If
    24.     Loop
    25.     Do
    26.         If IsNumeric(Right(sCaption, 1)) = True Or Right(sCaption, 1) = ")" Or Right(sCaption, 1) = " " Or Right(sCaption, 1) = ":" Then 'removes the number from the winamp currently playing song.
    27.         sCaption = Left(sCaption, Len(sCaption) - 1)
    28.         ElseIf Right(sCaption, 1) = "(" Then
    29.         sCaption = Left(sCaption, Len(sCaption) - 1)
    30.         Exit Do
    31.         Else
    32.         Exit Do
    33.         End If
    34.     Loop
    35.     getWinampWindow = sCaption 'sets the return value of the module to the edited sCaption strong, which now contains the song name and artist...
    36. Else
    37.     getWinampWindow = "Winamp 5 Series Not Found" 'sets the return value of the module to the edited sCaption string which has jut been set because the winamp title could not be found
    38. End If
    39. End Function

    Usage:

    Using this module is simple, no need to declare anything in your forms, no need to register anything, simply call "getWinampWindow" as if it was a string, for example :
    VB Code:
    1. msgbox getWinampWindow

    It could even be used in a timer to periodically update a Label to show the currently playing song. For example - (where SongUpdate is a timer, CurrentSong is a label)
    VB Code:
    1. Private sub SongUpdate_Timer()
    2. SongUpdate.Enabled = False
    3. CurrentSong.Caption = getWinampWindow
    4. SongUpdate.Enabled = True
    5. End Sub

    Experimenting with this you could record you very own music played log, although you would need to compare the two Listbox entries to make sure no songs appear more than once in a row, especially if used in a timer, you could make it only add the song if the song before it was different.
    Some pseudo-code for this would be -
    -----------------------------------------
    Get the last song (listindex = 0) and save it to a string
    Compare this string to getWinampWindow
    Add getWinampWindow if the two aren't equal
    Don;t add it if they are equal
    -----------------------------------------

    Enjoy

    I will attach a sample project as well.
    Attached Files Attached Files
    Last edited by thegreatone; May 3rd, 2005 at 09:52 AM.
    Zeegnahtuer?

  2. #2

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    I mentioned being able to create a decent logfile of your played songs... i gave Pseudo Code, now, i bring to you, and example using the very same module as before

    Here is the code for the main Form, i will comment it and show you what is going on :

    VB Code:
    1. Dim CurrSong As String 'this is where the current song will be stored, it will be used in comparisons later on, and so is important.
    2.  
    3. Private Sub Command1_Click()
    4. If Command1.Caption = "Start Logging Songs" Then 'checks to see the caption of the command button
    5. Command1.Caption = "Stop Logging Songs" 'changes the command buttons caption suitably
    6. Timer1.Enabled = True 'enables the simple timer that will be used to log songs
    7. Else:
    8. Timer1.Enabled = False 'turns the timer off
    9. Command1.Caption = "Start Logging Songs" 'changes the command buttons caption
    10. End If
    11. End Sub
    12.  
    13. Private Sub Command2_Click()
    14. On Error GoTo SAVE_ERROR 'error trapping
    15. Dim intX As Integer
    16. CD.Filter = "Text File (*.txt)|*.txt" 'set the output of the common dialog control to text files
    17. CD.ShowSave 'shows the common dialogs save menu
    18. Open CD.FileName For Output As #2
    19. For intX = 0 To List1.ListCount - 1 'loops through the listbox adding all the items to file
    20.     Print #2, List1.List(intX)
    21. Next
    22. Close #2
    23. Exit Sub
    24. SAVE_ERROR:
    25.     MsgBox Err.Num & " " & Err.Description, vbOKOnly, "" 'tells the end user what the error was
    26. End Sub
    27.  
    28. Private Sub Command3_Click()
    29. List1.Clear 'clears the log of songs
    30. End Sub
    31.  
    32. Private Sub Form_Load()
    33. Call Update 'Calling the update function straight away ensures the program id up-to-date with the currently playing song.
    34. End Sub
    35.  
    36. Function Update()
    37. Label1.Caption = getWinampWindow 'calls the module to gain the currently playing songs title
    38. End Function
    39.  
    40. Private Sub Timer1_Timer()
    41. Timer1.Enabled = False 'turns the timer off, just incase processing this Sub takes longer than expected.
    42. Label1.Caption = getWinampWindow 'updates the Label to display the currently playing song.
    43. CurrSong = getWinampWindow 'updates the currently playing song string via the module
    44. If Left(CurrSong, 9) = "[Opening]" Then CurrSong = Right(CurrSong, Len(CurrSong) - 10) 'strips the [opening] tag that may exist on the song if Winamp is struggling to open a particular file
    45. If List1.ListCount > 0 Then List1.ListIndex = 0
    46. If CurrSong = List1.Text Then 'if the same song is still playing as the last update then skip anything from now, and do not re-add the song to the log
    47. Else:
    48. List1.AddItem CurrSong, 0 'adds the currently playing song to the top of the list
    49. End If
    50. Timer1.Enabled = True 'turns the timer back on, so the process can be repeated again.
    51. End Sub

    The module mentioned is unchanged from the one posted above.
    Enjoy the use of this example

    Edit: Compiled .Exe removed from attachment - Hack
    Attached Files Attached Files
    Last edited by Hack; May 3rd, 2005 at 10:04 AM.
    Zeegnahtuer?

  3. #3

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 6 currently playing module.

    Sorry, i didn't notice that until last night when it was too late, BUT, the Winamp 5.xx Series is called Winamp 6 amongst many people i know, because they reason the Winamp original was actually Winamp 0.

    I will change the title
    And the code, but i shall leave the download how it is

    Did you find this code useful ?
    Zeegnahtuer?

  4. #4
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Here are some changes i'v donne to the module to try to fix a problem that i had with winamp modern skin, addeded id3v2 support to it and mpeg info reading too...

    VB Code:
    1. 'WinampMod - winamp.bas
    2. '
    3. 'By MidTerror - [email]midterror@hotmail.com[/email]
    4. '
    5. 'Updated by [url=http://www.vbforums.com/member.php?u=44830]Thegreatone[/url]
    6. '
    7. 'Re-Update by ME :=)
    8. '(problem opening id3 editor solved, working for
    9. 'winamp modern skin, addeded id3v2 tag reading support)
    10. 'improvement of ID3v1 and ID3v2 reading/checking
    11. 'addeded MPEG info reading, fixed getWinampWindowText bug
    12. '
    13. 'Feel free to mail comments, bugs, advice
    14. 'I'd appreciate it if you gave me some credit
    15. 'If you make a program out of this. If not
    16. 'then it's ok, but I wouldn't mind seeing the
    17. 'program, so feel free to send me programs you
    18. 'make with this.

    Quote Originally Posted by thegreatone
    Used like so -
    VB Code:
    1. FindWinamp
    2. getWinampWindowText
    3. GetMp3Info
    4. MsgBox MP3Info.id3v2_Album
    5. MsgBox MP3Info.id3v2_Artist
    6. MsgBox MP3Info.id3v2_Comment
    7. MsgBox MP3Info.id3v2_Composer
    8. MsgBox MP3Info.id3v2_Copyright
    9. MsgBox MP3Info.id3v2_EncodedBy
    10. MsgBox MP3Info.id3v2_Genre
    11. MsgBox MP3Info.id3v2_OrgArtist
    12. MsgBox MP3Info.id3v2_Title
    13. MsgBox MP3Info.id3v2_Track
    14. MsgBox MP3Info.id3v2_Url
    15. MsgBox MP3Info.id3v2_Year
    There you go

    Edit1: ID3v2 state checking (addeded)
    Edit2: Addeded MPEG info support (addeded)
    Edit3: ID3v1 state checking (addeded)
    Edit4: Fixed a little problem in getWinampWindowText:
    VB Code:
    1. 'sCaption = Left(sTitle, InStr(1, sTitle, vbNullChar, vbTextCompare) - 10)
    2.     'as sometimes it gave me bad title i put the following:
    3.  
    4.     sCaption = Left(sTitle, InStr(1, sTitle, vbNullChar, vbTextCompare))
    5.     sCaption = Replace(sCaption, " - Winamp", "")
    Attached Files Attached Files
    Last edited by TDQWERTY; Jan 18th, 2011 at 11:19 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  5. #5

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Well done TDQWERTY. Nice to see when we work together the bugs get ironed out
    Zeegnahtuer?

  6. #6
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: VB6 - Get Winamp 5.xx currently playing module.

    hehe true indeed, i might change that module soon...i wanted to add a mpeg info reading too but unfortunatly won't be this weekend.
    I'm trying to find out all the conts used in winamp to some things can be speeded up a bit.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  7. #7

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Quote Originally Posted by TDQWERTY
    hehe true indeed, i might change that module soon...i wanted to add a mpeg info reading too but unfortunatly won't be this weekend.
    I'm trying to find out all the conts used in winamp to some things can be speeded up a bit.
    That could get tricky very fast.

    I thik there is a way of making Winamp update your program automagically, i'm looking into it soon.
    Zeegnahtuer?

  8. #8
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: VB6 - Get Winamp 5.xx currently playing module.

    hmm winamp had to use a plugin to do such, but as far as i know can't be donne a plug-in for winamp in vb (my guess)

    Edit: MPEG info option addeded;
    ID3v1 and ID3v2 state checking as boolean (enabled/disabled)
    Last edited by TDQWERTY; Feb 10th, 2006 at 09:09 PM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  9. #9
    New Member
    Join Date
    May 2006
    Posts
    1

    Thumbs up Re: VB6 - Get Winamp 5.xx currently playing module.

    Great job Thegreatone & TDQWERTY. I have just begun to play with VB. Would you by chance have the same type of thing for Musicmatch? Specifically, I am looking for a way to access the ID3V2 tag info in Musicmatch. Any help is appreciated.

  10. #10
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: VB6 - Get Winamp 5.xx currently playing module.

    codebank isn't the right place to ask this type of thinks.
    but no, i'v never try that program.
    I have try this with winamp due to some fun controling 2 media boxes over the internet to my house...
    as far as i remember musicmatch was too heavy for this kind of things, although it migh be donne. It's all a mather of shorcuts and handles.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  11. #11

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Quote Originally Posted by L-B-P-O
    Great job Thegreatone & TDQWERTY. I have just begun to play with VB. Would you by chance have the same type of thing for Musicmatch? Specifically, I am looking for a way to access the ID3V2 tag info in Musicmatch. Any help is appreciated.
    Same here i'm afraid never used the program.

    However, the code used could also be re-used in a few ways to work with Musicmatch. I'm guessing with some work using Spy++ you could retrieve the information needed as we did.
    Zeegnahtuer?

  12. #12
    New Member
    Join Date
    Aug 2006
    Posts
    5

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Any chance of making this work with VB 2005 (express edition) ?

  13. #13

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    If you fancy converting it then yes, you could read up on the equivalents in VB.NET.

    Unfortunatly at this time i don't have the timne to be learning a new language, work is more important (and it takes way too much time up). Sorry.
    Zeegnahtuer?

  14. #14
    New Member
    Join Date
    Aug 2006
    Posts
    5

    Re: VB6 - Get Winamp 5.xx currently playing module.

    I'm a sort-a-noob to 2005 so can't convert this I have tried for about 3 hours

  15. #15

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Quote Originally Posted by FusionXN1
    I'm a sort-a-noob to 2005 so can't convert this I have tried for about 3 hours
    Is that telefragx by any chance over at geekbb? 2 people asking for the same thing in the same day...

    I'm certainly a n00b at vb.net 2005. I may take a look, but i doubt i can do it in such a limited amount of time.
    Zeegnahtuer?

  16. #16
    New Member
    Join Date
    Aug 2006
    Posts
    5

    Re: VB6 - Get Winamp 5.xx currently playing module.

    I, that's my old one Been tring to get it to work all dya no luck so time for a break.

  17. #17

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Ok, so i threw it through the converter and ended up with a workingversion, it has one bug i know of so far, that when winamp first loads it simply shows "wi" until you play a song.

    It's attached, but i'm unsure whether this is worthy of the codebank for .Net submisions.
    Attached Files Attached Files
    Zeegnahtuer?

  18. #18
    New Member
    Join Date
    Aug 2006
    Posts
    5

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Edited a little bit and got it working, now it shows say im playing Crash and Burn by Shortie it shows:

    - Winamp *** 1. Shortie - Crash and Burn

    How can i get the artist to Label1
    And the Track to Label2?

  19. #19

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4700 x4
    Posts
    1,333

    Re: VB6 - Get Winamp 5.xx currently playing module.

    It worked when i converted it, so the version above now works.

    To seperate the things to seperate labels use the split function.
    Zeegnahtuer?

  20. #20
    New Member
    Join Date
    Aug 2006
    Posts
    5

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Dont want to sound like an idiot but how can i remove everything but the artist and track and split them?

    EDIT: I have winamp scrolling in the task bar and it seems to do it in my app too
    Last edited by FusionXN1; Aug 17th, 2006 at 03:58 PM.

  21. #21
    New Member
    Join Date
    May 2009
    Posts
    1

    Re: VB6 - Get Winamp 5.xx currently playing module.

    Quote Originally Posted by thegreatone View Post
    I mentioned being able to create a decent logfile of your played songs... i gave Pseudo Code, now, i bring to you, and example using the very same module as before

    Here is the code for the main Form, i will comment it and show you what is going on :

    VB Code:
    1. Dim CurrSong As String 'this is where the current song will be stored, it will be used in comparisons later on, and so is important.
    2.  
    3. Private Sub Command1_Click()
    4. If Command1.Caption = "Start Logging Songs" Then 'checks to see the caption of the command button
    5. Command1.Caption = "Stop Logging Songs" 'changes the command buttons caption suitably
    6. Timer1.Enabled = True 'enables the simple timer that will be used to log songs
    7. Else:
    8. Timer1.Enabled = False 'turns the timer off
    9. Command1.Caption = "Start Logging Songs" 'changes the command buttons caption
    10. End If
    11. End Sub
    12.  
    13. Private Sub Command2_Click()
    14. On Error GoTo SAVE_ERROR 'error trapping
    15. Dim intX As Integer
    16. CD.Filter = "Text File (*.txt)|*.txt" 'set the output of the common dialog control to text files
    17. CD.ShowSave 'shows the common dialogs save menu
    18. Open CD.FileName For Output As #2
    19. For intX = 0 To List1.ListCount - 1 'loops through the listbox adding all the items to file
    20.     Print #2, List1.List(intX)
    21. Next
    22. Close #2
    23. Exit Sub
    24. SAVE_ERROR:
    25.     MsgBox Err.Num & " " & Err.Description, vbOKOnly, "" 'tells the end user what the error was
    26. End Sub
    27.  
    28. Private Sub Command3_Click()
    29. List1.Clear 'clears the log of songs
    30. End Sub
    31.  
    32. Private Sub Form_Load()
    33. Call Update 'Calling the update function straight away ensures the program id up-to-date with the currently playing song.
    34. End Sub
    35.  
    36. Function Update()
    37. Label1.Caption = getWinampWindow 'calls the module to gain the currently playing songs title
    38. End Function
    39.  
    40. Private Sub Timer1_Timer()
    41. Timer1.Enabled = False 'turns the timer off, just incase processing this Sub takes longer than expected.
    42. Label1.Caption = getWinampWindow 'updates the Label to display the currently playing song.
    43. CurrSong = getWinampWindow 'updates the currently playing song string via the module
    44. If Left(CurrSong, 9) = "[Opening]" Then CurrSong = Right(CurrSong, Len(CurrSong) - 10) 'strips the [opening] tag that may exist on the song if Winamp is struggling to open a particular file
    45. If List1.ListCount > 0 Then List1.ListIndex = 0
    46. If CurrSong = List1.Text Then 'if the same song is still playing as the last update then skip anything from now, and do not re-add the song to the log
    47. Else:
    48. List1.AddItem CurrSong, 0 'adds the currently playing song to the top of the list
    49. End If
    50. Timer1.Enabled = True 'turns the timer back on, so the process can be repeated again.
    51. End Sub

    The module mentioned is unchanged from the one posted above.
    Enjoy the use of this example

    Edit: Compiled .Exe removed from attachment - Hack
    I like this solution, but i need date and time when song is played.
    I believe that can be done with date and time stamp. As well, song duration would be interesting to add.
    So, can anyone help me how to add time stamp in this project ?
    Any kind of help would be good for me !

  22. #22
    New Member
    Join Date
    Jun 2011
    Posts
    1

    Lightbulb Re: VB6 - Get Winamp 6 currently playing module.

    Quote Originally Posted by thegreatone View Post
    Sorry, i didn't notice that until last night when it was too late, BUT, the Winamp 5.xx Series is called Winamp 6 amongst many people i know, because they reason the Winamp original was actually Winamp 0.

    I will change the title
    And the code, but i shall leave the download how it is

    Did you find this code useful ?
    Actually, there was no version "0". The real reason for the jump from 3 to 5 (ignoring 4) is hilarious.

    From the Winamp FAQ:
    You're not imagining things. Yes, we skipped a version number for the following reasons: a) Winamp 5 combines the best aspects of Winamp 2 and Winamp 3 into one player. Hence Winamp 2 + Winamp 3 = Winamp 5! b) Who the hell wants to see a Winamp 4 Skin :P c) We think that a Fibonacci sequence for versioning might be pretty damn cool. d)We improved so much in Winamp 5 that we figured it warranted skipping a version.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width