469,568 Members | 1,467 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

About Playsound

CM
There is a function called Playsound. But I think it can only play wav. I
don't know how to use it in .net application to play MP3 or rm music.
I am failed to find any sample code.
Anyone can help?
Thanks!
CM
Nov 16 '05 #1
1 3026
Hi CM
play sound is an API function . It is in the user32.dll file so you do a
platfom invocation to call it . to do so , you use the DLLImport attribute
with the relative arguments , then define the function as external . once
you have done so , you can use it from your code while passing to it the
file that you want to play
here is an exmple code of a c# program that show who
to use this function
First include this namespace
using System.Runtime.InteropServices;

then define the import attribute and the extern function as
follows ( you can do that any where in your program )
[DllImport("winmm.dll", EntryPoint="PlaySound")]
public static extern bool PlaySound_DllImport(string
pszSound,IntPtr hmod ,int fdwSound );
define its pram and use it as follows
bool result;
System.IntPtr resourceHandle = System.IntPtr.Zero;
result = PlaySound_DllImport("c:\\somefile.mpc3",resourceHa ndle,0);

you can read more about the function on the msdn online site
hope that would help
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.