Sound player in VB.NET Compiler Beta2 2005 Express Edition
Hi. Can someone tell me how to put a working sound player into the VB.NET 2005 Express Edition Beta2 I am having a little trouble, and I can't really figure out what it is. Is it a control If so, why isn't it in the Designer's Toolbox
Hi. I work with C#, not VB, but maybe you can 'translate' my answer.
SoundPlayer is no longer in the toolbox and is not even in the Forms namespace any more - it has been moved to System.Media but is still called SoundPlayer.
You have to manually add an instance of the SoundPlayer object to your code... in C#, you do it like this...
System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
To associate it with a WAV file...
sp.SoundLocation = "c:/windows/media/ding.wav";
and then use sp.Play() to play it whenever.
One other thing that you must do to prevent security errors... in Project/Properties/Security, tick off "Enable ClickOnce Security Settings" and leave "full trust application" selected.
The short answer is, you can't play anything other than WAVs with SoundPlayer. I think this is because any other sound format requires a decompression engine to be built in to the player.
There are a great many freeware and shareware sound file converters on the Internet, but if you convert, say, an MP3 to a WAV, the file size will end up huge.
You can probably find downloadable alternative player components for Visual Studio which can handle multiple file formats, but I haven't tried any - I've stuck to WAVs for my modest sound needs. Maybe somebody else who views this might suggest a good alternative, probably from GotDotNet or Sourceforge.
Me again... shortly after I posted the previous response, one of my students told me about the VB player component available from the following link...
All Right Man! It works. It would be nice to have .mid support, but I have a beautiful audio converter, so it won't be a problem. Thanks a ton. I have been wondering about this for quite some time now. Thanks again, The Digital Pioneer
Sound player in VB.NET Compiler Beta2 2005 Express Edition
Seericssop
PSRibeiro
Hi. I work with C#, not VB, but maybe you can 'translate' my answer.
SoundPlayer is no longer in the toolbox and is not even in the Forms namespace any more - it has been moved to System.Media but is still called SoundPlayer.
You have to manually add an instance of the SoundPlayer object to your code... in C#, you do it like this...
System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
To associate it with a WAV file...
sp.SoundLocation = "c:/windows/media/ding.wav";
and then use sp.Play() to play it whenever.
One other thing that you must do to prevent security errors... in Project/Properties/Security, tick off "Enable ClickOnce Security Settings" and leave "full trust application" selected.
Hope this works for you in VB.
ArunBandy
There are a great many freeware and shareware sound file converters on the Internet, but if you convert, say, an MP3 to a WAV, the file size will end up huge.
You can probably find downloadable alternative player components for Visual Studio which can handle multiple file formats, but I haven't tried any - I've stuck to WAVs for my modest sound needs. Maybe somebody else who views this might suggest a good alternative, probably from GotDotNet or Sourceforge.
Good luck!
Bruce H
It wont work for me, it keeps asking to Convert the Files using Conversion Wizard.
Do i need somthing, or am i missing somthing
mok
BALA SINGAM
http://www.gotdotnet.com/Community/UserSamples/Details.aspx SampleGuid=7f2a3d37-7e32-42f3-9909-76573493501b
Let me know if it works for you.
Tom Michaels
Thanks again,
The Digital Pioneer
SWhittet