|
-
Oct 13th, 2023, 09:41 AM
#1
Thread Starter
Addicted Member
VB.NET Run WMP Process Hidden or Minimized not working
Hi All, I am using this code to play a very short mp3, close it and re-run it. What I cannot figure out is how to run windows media player either hidden or minimized. I have tried several things with no luck. No matter what I try, the player window always appears. Thanks for any help!
Code:
Sub Alert()
Dim MyProcess As New Process
Dim proc = Process.GetProcessesByName("WMPlayer")
MyProcess.StartInfo.CreateNoWindow = True
MyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
MyProcess.StartInfo.FileName = "C:\alerts\audio_alert.mp3"
MyProcess.Start()
System.Threading.Thread.Sleep(5000)
For Each runproc As Process In Process.GetProcessesByName("WMPlayer")
runproc.Kill()
Next
End Sub
-
Oct 14th, 2023, 01:48 AM
#2
Re: VB.NET Run WMP Process Hidden or Minimized not working
Why do you start the wmp externally? You can use wmp control directly. Other alternatives would be to play the mp3 via e.g. the api mciSendString, via Bass.net or via the Media Foundation -> IMFMediaEngine(Ex).
-
Oct 14th, 2023, 07:26 AM
#3
Re: VB.NET Run WMP Process Hidden or Minimized not working
Use COM to create an WMP object and control it via that. I did the same in one of my .js desktop projects, I can't remember the VB6 syntax but the following extract from the .js won't be dissimilar.
This extract shows me controlling the WMP object and experimenting with the Winamp object, showing the commands available. It isn't code you can just run. You will have to research and adapt. I will be doing the same soon.
Code:
WMPlayer = COM.createObject("{6BF52A52-394A-11d3-B153-00C04F79FAA6}"); // the correct class ID for Windows Media Player 7
COM.connectObject(WMPlayer, "WMP_");
Winamp.setTrackRating(cTrackRating);
Winamp.setVolume(cVolume);
Winamp.setPlayerPosition(cSeekPos);
Winamp.playerStatus;
Winamp.running
Winamp.volume; WMPlayer.settings.volume = volume;
Winamp.shuffle==true) {
Winamp.repeat==true) {
Winamp.trackRating;
Winamp.trackTitle; WMPlayer.currentMedia.name
Winamp.trackArtist
Winamp.trackAlbum
Winamp.trackBitrate;
Winamp.trackSamplerate;
Winamp.playerPosition; WMPlayer.controls.currentPosition)
Winamp.trackLength; WMPlayer.currentMedia.duration
Winamp.doBackTrack();
Winamp.doNextTrack();
Winamp.doClose();
Winamp.doOpen();
Winamp.doStop();
Winamp.doPlayPause(); WMPlayer.controls.pause(); WMPlayer.controls.play(
Winamp.shuffle
Winamp.setShuffle(false);
Winamp.repeat
Winamp.setRepeat(false);
WMPlayer.URL)) >= 0);
WMPlayer.fullScreen = true;
WMPlayer.settings.mute);
WMPlayer.controls.quit(); // stop the QTPlayer app
COM.disconnectObject(WMPlayer); // release the WMPlayer
Last edited by yereverluvinuncleber; Oct 14th, 2023 at 07:33 AM.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Oct 16th, 2023, 08:49 AM
#4
Thread Starter
Addicted Member
Re: VB.NET Run WMP Process Hidden or Minimized not working
Thanks for the replies. I will look into this and see if I can find something on it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|