Ok, I have been using Microsoft's SAPI, to "well try to do everything"
And have had alot of success. I can open applications, play music, calculate math equations, and even retreive defenitions of words from "www.dictionary.com" using WinSock.

I designed it, much like StarTrek TNG. I say "computer" and the sound from the TV show plays, then I can give commands.

OK, now I have a new Sub that opens WinAmp and a specific radio station.

It actually opens a browser with a specific string, then the browser opens WinAmp and the music plays.

Sub PlayGenre(ByVal strGenre As String)
' plays a sound letting me know the command was recognized
        PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")

' trying to get a handle on WinAmp
        Dim myProcess As Process = New Process
        myProcess.StartInfo.FileName = "winamp.exe"

' determine what genre was asked for and open the webpage 
        Select Case strGenre
            Case "jazz"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
            Case "house"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6151&file=filename.pls")
            Case "rock alternative"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7659&file=filename.pls")
            Case "blues"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6999&file=filename.pls")
            Case "new Orleans"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7421&file=filename.pls")
            Case "big band"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=1160&file=filename.pls")
            Case "alternative"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=5004&file=filename.pls")
            Case Else
                myProcess.Kill() ' if not recognized try to close winamp
        End Select
    End Sub

I am trying to close the WinAmp Application using

' called at the beginning of the SUB
        Dim myProcess As Process = New Process
        myProcess.StartInfo.FileName = "winamp.exe"
'
' then in any case else situation
            Case Else
                myProcess.Kill()

But this isn't working.

I am thinking maybe I need to instead of calling the webpage, that I need to open WinAmp as a Shell statement and somehow pass what station I want to play. I would have control over the handle.

I'll pop over to the WinAmp forums, but I doubt they will be much help.

Im not much of a VB.Net guy, but In I think you would need to write out the whole path.

myProcess.StartInfo.FileName = "C:\\Program Files\\Winamp\\winamp.exe"

Let me know if that works.

Nope.

But thanks for the reply.

Goint to try referencing Winamp and see what I can do from there:

Dim WinAmp As New WinAmpXLib.IWinAmpActiveX

So far I don't see any cammands refering to the radio stations accept maybe

winamp.GetURLToLaunch("http://blah")

But there are 2 other references available yet for me to explore.

Dim WinAmp2 As New WinAmpXLib.IWinAmpActiveXClass
    Private WinAmp3 As WinAmpXLib._IWinAmpXEvents_SinkHelper

So I'll have to see what I can do with these...

( should have thought of this in the first place... :rolleyes:

I also might try referencing Windows Media Player
Probably more available documentation anyways....

Stupid Winamp SDK is entirely C++
( fascist pig dogs I spit on them "ptooey!!" )

juskidding...

Well that works (sorta)
The program closes an app based on the name of the process in the Task Manager : example - It would close a program called "My Program" just fine. But if I try to close WinAmp, it won't close because what is the name of the application running would be the name of the song, and other information i.e. "125 - Song Title - Song Genre - WinAmp"

And that changes on a regular basis.

Even though in the process menu the name of WinAmp is "winamp.exe"

So again I need to to figure out how to use the Active control to return what song is playing, then I can use that information to close the app.

BUT, thanks, this put me on the right track I think.

Hi,

This is an easy one; you don't even use the :
---
Dim myProcess As Process = New Process
myProcess.StartInfo.FileName = "winamp.exe"
---
System.Diagnostics.Process.Start("...") returns you a reference to the newly created process, you must keep it (outside of sub, not as a local var) but as you don't assign it to anything, it gets lost. Just use

private myProcess As Process

on your class (don't even instantiate) to keep the ref. And call like

myProcess = System.Diagnostics.Process.Start("...")

on each case; then you can directly call myProcess.Kill anywhere. Remember to kill the previous process before starting a new one or keep a separate ref to each of your processes.

Loren Soth

Thanks for the reply , but I must be doing something wrong.

' Declaration

Private extApplication As Process

' //////

Select Case strGenre
Case "jazz"
extApplication = System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")

etc....

' WinAmp opens fine


Select Case LCase(strText)
Case "blah"
'//
Case "blah"
' //
Case "close radio"
PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c44.wav")
extApplication.Kill()
End Select


The WAV plays so I know it gets this far, but the application isn't killed

I think the problem is that when I open WinAmp

extApplication = System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=8234&file=filename.pls")

I am actually opening Internaet Explorer to a URL, then thier script opens Winamp to play the music. Therefore extAplication is actually tied to the instance of IE or is empty.

I need to learn how to Shell Winamp with a specific URL
Open WinAmp then pass a command to it.

I've read about passing keys to applications ( notepad ) , and even found some examples using WinAmp, but none that use the radio.

Ultimatly, the best solution would be to use a socket connection and play the music as a streaming MP3 file. ( remove the external player all together )

I have found SOME information about that, but have yet to explore it. The examples were for recording the streaming data to a file, but not playing it.

I can already play MP3 files off my hard drive, specified by genre, song title, or random, and that's really enough...
This part of my project will take some time, and I will likely just put it on the back-burner for now, and work on something else.

Phase II involves object recognition via a webcam...
( well actually for now just recognizing that the image has changed )
One step at a time....

Thanks agin for the reply

Ok, I have been using Microsoft's SAPI, to "well try to do everything"
And have had alot of success. I can open applications, play music, calculate math equations, and even retreive defenitions of words from "www.dictionary.com" using WinSock.

I designed it, much like StarTrek TNG. I say "computer" and the sound from the TV show plays, then I can give commands.

OK, now I have a new Sub that opens WinAmp and a specific radio station.

It actually opens a browser with a specific string, then the browser opens WinAmp and the music plays.

Sub PlayGenre(ByVal strGenre As String)
' plays a sound letting me know the command was recognized
        PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")

' trying to get a handle on WinAmp
        Dim myProcess As Process = New Process
        myProcess.StartInfo.FileName = "winamp.exe"

' determine what genre was asked for and open the webpage 
        Select Case strGenre
            Case "jazz"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
            Case "house"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6151&file=filename.pls")
            Case "rock alternative"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7659&file=filename.pls")
            Case "blues"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6999&file=filename.pls")
            Case "new Orleans"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7421&file=filename.pls")
            Case "big band"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=1160&file=filename.pls")
            Case "alternative"
                System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=5004&file=filename.pls")
            Case Else
                myProcess.Kill() ' if not recognized try to close winamp
        End Select
    End Sub

I am trying to close the WinAmp Application using

' called at the beginning of the SUB
        Dim myProcess As Process = New Process
        myProcess.StartInfo.FileName = "winamp.exe"
'
' then in any case else situation
            Case Else
                myProcess.Kill()

But this isn't working.

I am thinking maybe I need to instead of calling the webpage, that I need to open WinAmp as a Shell statement and somehow pass what station I want to play. I would have control over the handle.

I'll pop over to the WinAmp forums, but I doubt they will be much help.

Hello,

wimamp is not a utility in OS, so u have to mention the full path of this in ur program then only it will work

All the best

That didn't work, but this did, well sorta.

extApplication = System.Diagnostics.Process.Start("C:\Program Files\Winamp\winamp.exe")
WinAmp.AppendFileToPlaylist("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
WinAmp.Play()

I used your code to opne WinAmp, then I used an Active control bundled with Winamp to control it.

I was unable to use the ActiveX control before. ( I didn't have a handle )

The problem now is that the voice activation program is normally minimized. This only seems to work if the program is maximized.

I tried this:

WinAmp = System.Diagnostics.Process.Start("C:\Program Files\Winamp\winamp.exe")
WinAmp.AppendFileToPlaylist("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
WinAmp.Play()

But no good...

OK Wait, this works... It's ugly, but it works...

Select Case strGenre
            Case "jazz"
                Me.WindowState = System.Windows.Forms.FormWindowState.Normal
                Me.ShowInTaskbar = True
                extApplication = System.Diagnostics.Process.Start("C:\Program Files\Winamp\winamp.exe")
                WinAmp.AppendFileToPlaylist("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
                WinAmp.Play()
                Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
                Me.ShowInTaskbar = False

This obviously sets the window to normal, momentarily, then does it's task, then minimizes again.

The strange thing is, that to stop the music playing, does not require me to do this.

Now I need to be able to change stations.

How would I check if extApplication has any value?

I tried:
If extApplication <> 0 Then
' do events
End if

and

If extApplication <> "" Then
' do events
End if

But of course extApplication is neither a string nor integer so an error was produced.

I tried
extApplication.kill()
' then open winamp

but that didn't open anything.

Wait,,, what am I stupid...
A regular boolean variable....

I'll get back to you.

Ok this is a little confusing, but works perfectly:

Select Case strGenre
            Case "jazz"
                If boolRadioIsPlaying = False Then
                    boolRadioIsPlaying = True
                Me.WindowState = System.Windows.Forms.FormWindowState.Normal
                Me.ShowInTaskbar = True
                    'extApplication = System.Diagnostics.Process.Start("C:\Program Files\Winamp\winamp.exe")
                    strCurrentStation = "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls"
                    WinAmp.AppendFileToPlaylist(strCurrentStation)
                    WinAmp.Play()
                    Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
                    Me.ShowInTaskbar = False
                Else
                    WinAmp.ClearPlaylist()
                    strCurrentStation = "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls"
                    WinAmp.AppendFileToPlaylist(strCurrentStation)
                    WinAmp.Play()
                End If

Notice I removed the extApplication altogether...
For some reason now the ActiveX control is working.

I think maybe before I was just not getting a connection to the server. ( likely the server was full )

Now I guess I will need to find a way to return if the server is full, and pass a message to the user.

In any case thanks again. Now I know a better way to open and control Apps in VB>NET versus using Shell like in the past.

Thanks!

Ok here's the final code:

Sub PlayGenre(ByVal strGenre As String)
        PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")
        Select Case strGenre
            Case "jazz"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
            Case "house"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6151&file=filename.pls")
            Case "rock alternative"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=3211&file=filename.pls")
            Case "rock alternative to"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7659&file=filename.pls")
            Case "blues"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6999&file=filename.pls")
            Case "new Orleans"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7421&file=filename.pls")
            Case "big band"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=1160&file=filename.pls")
            Case "experimental"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=8952&file=filename.pls")
            Case "industrial"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=113553&file=filename.pls")
            Case "psychedelic"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=222275&file=filename.pls")
            Case "classical contemporary"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=307275&file=filename.pls")
            Case "classic rock"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=716112&file=filename.pls")
            Case "classic rock to"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=8234&file=filename.pls")
            Case "hip hop"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=2834&file=filename.pls")
            Case "dirty south"
                Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=9956&file=filename.pls")
            Case Else
                PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")
                Voice.Speak("Music genre unknown. Please re-specify", SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
        End Select
    End Sub

'--------------------------------------------------

Sub PlayRadio(ByVal strCurrentStation As String)
        If boolRadioIsPlaying = False Then
            boolRadioIsPlaying = True
            Me.WindowState = System.Windows.Forms.FormWindowState.Normal
            Me.ShowInTaskbar = True
            WinAmp.AppendFileToPlaylist(strCurrentStation)
            WinAmp.Play()
            Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
            Me.ShowInTaskbar = False
        Else
            WinAmp.ClearPlaylist()
            WinAmp.AppendFileToPlaylist(strCurrentStation)
            WinAmp.Play()
        End If
    End Sub

BTW - How do I set this post as being solved?

Or does the MOD do that?

Just try this one if works..

Dim myProcesses() As Process = Process.GetProcesses
Dim myProcess As Process
For Each myProcess In myProcesses
If (myProcess.ProcessName.ToLower = "winamp") Then
myProcess.Kill()
End If
Next

Hope it helps............

Hi, not sure if this will help, but try it anyway.

Dim taskKill As New ProcessStartInfo("taskkill", "/F /IM winamp.exe")
        taskKill.WindowStyle = ProcessWindowStyle.Hidden

        Dim process As New Process()

        process.StartInfo = taskKill

        process.Start()

        process.WaitForExit()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.