문제

I'm trying to embed and then play back a .wav file in a C++/CLI app but all the examples I've seen which use PlaySound are in VB. I can't see how to get froma Stream^ to the LPCSTR which PlaySound requires:

System::IO::Stream^ s = Assembly::GetExecutingAssembly()->GetManifestResourceStream ("Ping.wav");

LPCSTR buf = s->????;

PlaySound(buf, NULL, SND_ASYNC|SND_MEMORY|SND_NOWAIT);

I guess I need some sort of horrible .net memory conversion magic.

도움이 되었습니까?

해결책

Use the System::Media::SoundPlayer class instead. It has a Stream property, assign your "s" variable to it, then call the Play() method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top