SoundPlayer from resource in CF3.5

M

magic gooddy

Hi!
I using wav-file from resource without problem in desktop application in
NF3.5
soundPlayer.Stream = Properties.Resources.tada;
soundPlayer.Play();

When I try this code in CF3.5 I got error "Cannot convert byte[] in Stream"

Help me, please
 
S

Simon Hart [MVP]

That's because the SoundPlayer class expects a Stream not a byte array. Try
the following code:

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

magic gooddy

Thank you very much

Simon Hart said:
That's because the SoundPlayer class expects a Stream not a byte array.
Try
the following code:

System.IO.MemoryStream m = new
System.IO.MemoryStream(Properties.Resources.tada);
System.Media.SoundPlayer sound = new
System.Media.SoundPlayer(m);
sound.Play();
m.Dispose();
}
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


magic gooddy said:
Hi!
I using wav-file from resource without problem in desktop application in
NF3.5
soundPlayer.Stream = Properties.Resources.tada;
soundPlayer.Play();

When I try this code in CF3.5 I got error "Cannot convert byte[] in
Stream"

Help me, please
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top