Closing external application

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Closing external application

 
0
  #11
Apr 6th, 2006
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
Best regards,
Loren Soth

Crimson K. Software _________________________________________________________________ Crimson K. Blog
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 1
Reputation: rittusuman is an unknown quantity at this point 
Solved Threads: 0
rittusuman rittusuman is offline Offline
Newbie Poster

Re: Closing external application

 
0
  #12
Apr 7th, 2006
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.

  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

  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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 28
Reputation: jerMAn is an unknown quantity at this point 
Solved Threads: 0
jerMAn jerMAn is offline Offline
Light Poster

Re: Closing external application

 
0
  #13
Apr 7th, 2006
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...

  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 28
Reputation: jerMAn is an unknown quantity at this point 
Solved Threads: 0
jerMAn jerMAn is offline Offline
Light Poster

Re: Closing external application

 
0
  #14
Apr 7th, 2006
Ok this is a little confusing, but works perfectly:

  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!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 28
Reputation: jerMAn is an unknown quantity at this point 
Solved Threads: 0
jerMAn jerMAn is offline Offline
Light Poster

Re: Closing external application

 
0
  #15
Apr 7th, 2006
Ok here's the final code:

  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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC