943,621 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 20552
  • VB.NET RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Apr 6th, 2006
0

Re: Closing external application

Hi,

Try :

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

You might need to put full path to winamp.exe if it isn't in your PATH encironment variable.

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Apr 7th, 2006
0

Re: Closing external application

Quote originally posted by jerMAn ...
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.

VB.NET Syntax (Toggle Plain Text)
  1. Sub PlayGenre(ByVal strGenre As String)
  2. ' plays a sound letting me know the command was recognized
  3. PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")
  4.  
  5. ' trying to get a handle on WinAmp
  6. Dim myProcess As Process = New Process
  7. myProcess.StartInfo.FileName = "winamp.exe"
  8.  
  9. ' determine what genre was asked for and open the webpage
  10. Select Case strGenre
  11. Case "jazz"
  12. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
  13. Case "house"
  14. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6151&file=filename.pls")
  15. Case "rock alternative"
  16. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7659&file=filename.pls")
  17. Case "blues"
  18. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6999&file=filename.pls")
  19. Case "new Orleans"
  20. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7421&file=filename.pls")
  21. Case "big band"
  22. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=1160&file=filename.pls")
  23. Case "alternative"
  24. System.Diagnostics.Process.Start("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=5004&file=filename.pls")
  25. Case Else
  26. myProcess.Kill() ' if not recognized try to close winamp
  27. End Select
  28. End Sub

I am trying to close the WinAmp Application using

VB.NET Syntax (Toggle Plain Text)
  1. ' called at the beginning of the SUB
  2. Dim myProcess As Process = New Process
  3. myProcess.StartInfo.FileName = "winamp.exe"
  4. '
  5. ' then in any case else situation
  6. Case Else
  7. 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rittusuman is offline Offline
1 posts
since Apr 2006
Apr 7th, 2006
0

Re: Closing external application

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...

VB.NET Syntax (Toggle Plain Text)
  1. Select Case strGenre
  2. Case "jazz"
  3. Me.WindowState = System.Windows.Forms.FormWindowState.Normal
  4. Me.ShowInTaskbar = True
  5. extApplication = System.Diagnostics.Process.Start("C:\Program Files\Winamp\winamp.exe")
  6. WinAmp.AppendFileToPlaylist("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
  7. WinAmp.Play()
  8. Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
  9. 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.
Reputation Points: 10
Solved Threads: 0
Light Poster
jerMAn is offline Offline
28 posts
since Jun 2005
Apr 7th, 2006
0

Re: Closing external application

Ok this is a little confusing, but works perfectly:

VB.NET Syntax (Toggle Plain Text)
  1. Select Case strGenre
  2. Case "jazz"
  3. If boolRadioIsPlaying = False Then
  4. boolRadioIsPlaying = True
  5. Me.WindowState = System.Windows.Forms.FormWindowState.Normal
  6. Me.ShowInTaskbar = True
  7. 'extApplication = System.Diagnostics.Process.Start("C:\Program Files\Winamp\winamp.exe")
  8. strCurrentStation = "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls"
  9. WinAmp.AppendFileToPlaylist(strCurrentStation)
  10. WinAmp.Play()
  11. Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
  12. Me.ShowInTaskbar = False
  13. Else
  14. WinAmp.ClearPlaylist()
  15. strCurrentStation = "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls"
  16. WinAmp.AppendFileToPlaylist(strCurrentStation)
  17. WinAmp.Play()
  18. 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!
Reputation Points: 10
Solved Threads: 0
Light Poster
jerMAn is offline Offline
28 posts
since Jun 2005
Apr 7th, 2006
0

Re: Closing external application

Ok here's the final code:

VB.NET Syntax (Toggle Plain Text)
  1. Sub PlayGenre(ByVal strGenre As String)
  2. PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")
  3. Select Case strGenre
  4. Case "jazz"
  5. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6390&file=filename.pls")
  6. Case "house"
  7. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6151&file=filename.pls")
  8. Case "rock alternative"
  9. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=3211&file=filename.pls")
  10. Case "rock alternative to"
  11. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7659&file=filename.pls")
  12. Case "blues"
  13. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6999&file=filename.pls")
  14. Case "new Orleans"
  15. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=7421&file=filename.pls")
  16. Case "big band"
  17. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=1160&file=filename.pls")
  18. Case "experimental"
  19. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=8952&file=filename.pls")
  20. Case "industrial"
  21. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=113553&file=filename.pls")
  22. Case "psychedelic"
  23. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=222275&file=filename.pls")
  24. Case "classical contemporary"
  25. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=307275&file=filename.pls")
  26. Case "classic rock"
  27. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=716112&file=filename.pls")
  28. Case "classic rock to"
  29. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=8234&file=filename.pls")
  30. Case "hip hop"
  31. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=2834&file=filename.pls")
  32. Case "dirty south"
  33. Call PlayRadio("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=9956&file=filename.pls")
  34. Case Else
  35. PlayWav("C:\VB6SBS\TTS testing\New Folder (3)\c55.wav")
  36. Voice.Speak("Music genre unknown. Please re-specify", SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
  37. End Select
  38. End Sub
  39.  
  40. '--------------------------------------------------
  41.  
  42. Sub PlayRadio(ByVal strCurrentStation As String)
  43. If boolRadioIsPlaying = False Then
  44. boolRadioIsPlaying = True
  45. Me.WindowState = System.Windows.Forms.FormWindowState.Normal
  46. Me.ShowInTaskbar = True
  47. WinAmp.AppendFileToPlaylist(strCurrentStation)
  48. WinAmp.Play()
  49. Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
  50. Me.ShowInTaskbar = False
  51. Else
  52. WinAmp.ClearPlaylist()
  53. WinAmp.AppendFileToPlaylist(strCurrentStation)
  54. WinAmp.Play()
  55. End If
  56. End Sub

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

Or does the MOD do that?
Reputation Points: 10
Solved Threads: 0
Light Poster
jerMAn is offline Offline
28 posts
since Jun 2005
Feb 4th, 2010
0
Re: Closing external application
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............
Reputation Points: 10
Solved Threads: 0
Newbie Poster
denjay is offline Offline
1 posts
since Feb 2010
Feb 4th, 2010
0
Re: Closing external application
Hi, not sure if this will help, but try it anyway.
VB.NET Syntax (Toggle Plain Text)
  1. Dim taskKill As New ProcessStartInfo("taskkill", "/F /IM winamp.exe")
  2. taskKill.WindowStyle = ProcessWindowStyle.Hidden
  3.  
  4. Dim process As New Process()
  5.  
  6. process.StartInfo = taskKill
  7.  
  8. process.Start()
  9.  
  10. process.WaitForExit()
Reputation Points: 18
Solved Threads: 3
Light Poster
Nattynooster is offline Offline
41 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Code to displays Days of users
Next Thread in VB.NET Forum Timeline: Start Menu Items





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC