Solved

Winamp and Visual Basic

Posted on 2001-08-17
11
882 Views
Last Modified: 2013-11-25
Okay Im writing a little interface program for winamp w/VB. I have been to their develpoer forums and no one seems to know why this code doesn't work.    
Ok, this is a snippet of my code fom VB...

==========================================================Private Const WM_USER = &H400
Private Const MODE = 1
Private Const IPC_GETTIME = 105
Dim s as Long

Private Sub Command6_Click()

s = SendMessage(hwndWinamp, WM_USER, MODE, IPC_GETTIME)
MsgBox s

End Sub
==========================================================This code is supposed to return the current songs position
in seconds. The only value it ever returns is 1. It will not give time in Seconds. Just a value of one. Does anybody see anything wrong or suggest anything. ( I use findwindow API to get the Hwnd of Winamp.)

nongravity
0
Comment
Question by:nongravity
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6398364
I can't say for certain, but I would venture a guess that the Window Message you need to send to hwndWinamp is a certain value plus WM_USER.

WM_USER is a base-point reference for messages for private window classes.
0
 

Author Comment

by:nongravity
ID: 6398415
here is an example from the SDK for Winamp (its in C++ but I ported it to VB,real simple)

--------------------------------------
#define IPC_GETOUTPUTTIME 105
/*
** int res = SendMessage(hwnd_winamp,WM_MA_IPC,mode,IPC_GETOUTPUTTIME);
**
** IPC_GETOUTPUTIME returns the position in milliseconds
** of the current (mode = 0), or the song length, in
** seconds(mode = 1).
** Returns -1 if not playing, 1 on EOF, or 0 if successful
*/


0
 

Author Comment

by:nongravity
ID: 6398426
I forgot to mention that the constant WM_MA_IPC is defined as WM_USER.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:DennisBorg
ID: 6398505
Assuming your definition of WM_MA_IPC is correct (that it equals WM_USER and not something like WM_USER + 1), then I do not see any error off hand.
0
 
LVL 32

Expert Comment

by:bhess1
ID: 6399167
Docs on Winamp's site indicate the problem is probably in your definition of SendMessage!  Define the last paramater as ByVal Long instead of Any and you should be able to get your return value correctly.
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 75 total points
ID: 6399170
So, you can use:

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Or declare a SendMessageLong type:

Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

and use it, retaining the default SendMessage definition.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6399756
Interesting matter, i would like to know how it ends...
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6399761
have a look in these examples, you maybe able to see where you going wrong

I was looking for a winamp code that went beyong the normal play, pause, and stop functions. When I couldn't find it, i made it myself. This is the best winamp module on planetsourcecode, it does more than just play and stop, it can get song length, get
http://www.planetsourcecode.com/xq/ASP/txtCodeId.13598/lngWId.1/qx/vb/scripts/ShowCode.htm


Here's the updated winamp module (Use to be "A winamp module like no other") This has lots of new features such as open winamp, play files, get file path, and tons more. You must get the updated one if you had the old one
http://www.planetsourcecode.com/xq/ASP/txtCodeId.4832/lngWId.1/qx/vb/scripts/ShowCode.htm


A .bas module containing procedures that are useful to control Winamp via its API. It contains the basic functions, and is easily expandable to include desired functions, with the help of the data sheet found at the NSDN page at the Winamp site. Thoroughl ...(description truncated
http://www.planetsourcecode.com/xq/ASP/txtCodeId.4922/lngWId.1/qx/vb/scripts/ShowCode.htm


Just set you're volume or balance with two simple controls or set the position of the media. They can be used in every MP3 player. Currently they used Winamp skins but the code is easy to change to other formats
http://www.planetsourcecode.com/xq/ASP/txtCodeId.9634/lngWId.1/qx/vb/scripts/ShowCode.htm

cheers
Andy
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6400217
interesting to me too..
0
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6405941
>Docs on Winamp's site indicate the problem is probably in
>your definition of SendMessage!  Define the
>last paramater as ByVal Long instead of Any and you
>should be able to get your return value correctly.

bhess, I suspect you're right.
0
 

Author Comment

by:nongravity
ID: 6406016
It works now!  I knew it was something simple but it was escaping me as to what the problem was. Thanks for everybody elses input on the matter.

nongravity
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dialogbox API leak? 18 98
Spell Check in VB6 13 126
Zip Folders Using Chilkat Routines 1 58
how to loop through and process two columns in excel 8 22
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question