PDA

View Full Version : Problem with launching Winamp using VB.NET


Kira_26
1st February 2007, 13:25
Does anybody know what the code to launch and play a certain song on winamp automatically in Visual Basic.NET? i am having a problem in playing a song cos Winamp will regard the file argument as a separate lines in the playlist. Thanks a lot for the help. :)

! 007robert !
1st February 2007, 14:04
I had meet same question (not VB), some one tell me WinAMP SDK can do it.

http://download.nullsoft.com/winamp/beta/WA5.32_SDK.exe

Tardymo
2nd February 2007, 09:32
Try enclosing a path to file in quotes.

Kira_26
4th February 2007, 00:44
I have tried that way and it can't work as well

Joel
4th February 2007, 16:25
Well... I have this:

' Module1
Module Module1
<System.Runtime.InteropServices.DllImport("shell32.dll", EntryPoint:="ShellExecute")> _
Public Function ShellExecute( _
ByVal hwnd As IntPtr, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
End Function

Public Sub Execute(ByVal hwnd As IntPtr, ByVal exeName As String, ByVal cmdLine As String)
ShellExecute(hwnd, vbNullString, exeName, cmdLine, vbNullString, 1)
End Sub
End Module

Somewhere in my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With Me.FolderBrowserDialog1
.SelectedPath = System.Environment.CurrentDirectory()
If (.ShowDialog(Me) <> DialogResult.Cancel) Then
Me.TextBox1.Text = .SelectedPath & "\Winamp.exe"
End If
End With
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
With Me.OpenFileDialog1
.InitialDirectory = System.Environment.CurrentDirectory()
If (.ShowDialog(Me) <> DialogResult.Cancel) Then
Me.TextBox2.Text = .FileName
End If
End With
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim file As String = Chr(34) & Me.TextBox2.Text & Chr(34)
Execute(Me.Handle, Me.TextBox1.Text, file)
End Sub
End Class

This should give you a head-start

Kira_26
5th February 2007, 02:13
thanks a lot for your help, i will try out this one. ^^

Kira_26
5th February 2007, 07:30
i have tried your code and execute it successfully. however, i encounter a new problem now cos i can't stop the player at predefined time. is there any alternative to stop the player at preset time?
i used Process class Wait*****it() method to stop other media player in predefined time. but i have no idea in shell funcion

Joel
5th February 2007, 14:10
Use a timer with:

#define IPC_GETOUTPUTTIME 105
/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETOUTPUTTIME);
** This api can return two different sets of information about current playback status.
**
** If mode = 0 then it will return the position (in ms) of the currently playing track.
** Will return -1 if Winamp is not playing.
**
** If mode = 1 then it will return the current track length (in seconds).
** Will return -1 if there are no tracks (or possibly if Winamp cannot get the length).
*/

or..

#define WINAMP_BUTTON4 40047 // stop button

at any time

Kira_26
6th February 2007, 00:38
thanks for your help. ^^

Kira_26
6th February 2007, 06:35
Originally posted by Joel
Use a timer with:

or..

at any time

can u pls gimme some explanation about your code and where should i put it? cos i am a bit confused. thanks a lot

Joel
6th February 2007, 14:49
Where to put what?
Timer, IPC_GETOUTPUTTIME, WINAMP_BUTTON4?

Kira_26
7th February 2007, 04:00
yes, cos i am not sure where to put the variables. thanks

Joel
7th February 2007, 18:23
Originally posted by Kira_26
yes, cos i am not sure where to put the variables. thanks
Oh! I see...try to learn more VB, than..after that you'll know how to use them... Remember this is Winamp Development forum, no helping in a specific language...beside, I already give you all the help you need.

Kira_26
8th February 2007, 05:06
ok, thanks a lot