⌘BABAKOV.NET Let's code!
100% [light] [ru]

How to Teach a PDA to Play WAV Files in .NET CF

A mobile device with .NET CF version 3.5 (and hopefully higher) support can be easily taught to play media files in the .WAV format. From this version, .NET CF has the necessary set of functions for playing sound files.

Without further ado, simply provide examples, they are elementary and very simple.

Two examples of playing a sound file:

Example #1

System.Media.SoundPlayer player = new System.Media.SoundPlayer(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\\\mysound.wav");
player.Play();


In this example, the mysound.wav file will be played, which should be located in the same folder as the application on the device.

And here is the difference in playing a sound file from resources, unlike ordinary .net

Example #2

System.IO.MemoryStream m = new System.IO.MemoryStream(Properties.Resources.MySound);
System.Media.SoundPlayer sound = new System.Media.SoundPlayer(m);
sound.Play();
m.Dispose();


In this example, the MySound sound file is played from resources.

That's all.

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.