Play embedded non-WAV sounds without COM components?

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

The subject says it all really, but to emphasise that I don't wan't to play
WAVs (too big: MP3 or WMA would be better) and the sound file must be
embedded. Also, I want to ensure that the executable is a stand-alone. (That
is, it isn't accompanied by COM dlls, for example. This may sound a bit mad,
but it has to be implemented as a single file - please don't ask why. :-) )

I've trawled through the Internet for this and come up with:
1. Use PlaySound from winmm.dll. AFAICT, this only plays WAV files, so no
good there. certainly, I could only get it to work with WAV files.
2. Use mciSendString from winmm.dll. Again, AFAICT, this does play other
format, but can't play embedded sound files. (Well, all the samples I've
seen open up files from the file system. I've spent a long time playing with
mciSendString to no avail.)
3. Use the Media Player control. This is implemented as a COM control - very
feature-rich, one - but I end up having to cart a couple of WMP dlls around
with me.
4. Write my own managed code to convert the embedded WMA to WAV on-the-fly
and then use PlaySound to play the file. Pheweee! If this is the only
option, I'm bailing out now because this isn't a trivial task.

I kind of think that there must be an easy way to do this, but I just can't
see how. Any idea?

TIA
Mark
 
Forgot to add...

Mark said:
The subject says it all really, but to emphasise that I don't wan't to play
WAVs (too big: MP3 or WMA would be better) and the sound file must be
embedded. Also, I want to ensure that the executable is a stand-alone. (That
is, it isn't accompanied by COM dlls, for example. This may sound a bit mad,
but it has to be implemented as a single file - please don't ask why. :-) )

I've trawled through the Internet for this and come up with:
1. Use PlaySound from winmm.dll. AFAICT, this only plays WAV files, so no
good there. certainly, I could only get it to work with WAV files.
2. Use mciSendString from winmm.dll. Again, AFAICT, this does play other
format, but can't play embedded sound files. (Well, all the samples I've
seen open up files from the file system. I've spent a long time playing with
mciSendString to no avail.)
3. Use the Media Player control. This is implemented as a COM control - very
feature-rich, one - but I end up having to cart a couple of WMP dlls around
with me.
4. Write my own managed code to convert the embedded WMA to WAV on-the-fly
and then use PlaySound to play the file. Pheweee! If this is the only
option, I'm bailing out now because this isn't a trivial task.

I kind of think that there must be an easy way to do this, but I just can't
see how. Any idea?

5. Embed the WMA file and then extract it to a temporary file in the file
system and use mciSendString("play myfile.wma", blah, blah, blah), followed
by deleting the temp file. This idea actually works, but it's really clunky!
If I could just do this without the temp file, I'd be onto something...

:-)

Mark
 
Back
Top