Re: sndPlaySound Wont play
Quote:
Originally Posted by
rentagoth
I was trying to play a .wav file from my app path with
PlaySound("BELLS.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
Well, it is obvious that the "current working directory" might be not the same as the one containing "BELLS.wav" file.
You have to pass in the full pathe name to the PlaySound call.
Quote:
Originally Posted by
rentagoth
An used this code to try to play it
sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1), SND_RESOURCE |SND_ASYNC );
1. Of course, it is wrong. And it cannot just compile!
You forgot the second parameter that must be the handle to the executable file that contains the resource to be loaded.
The correct call should look like:
Code:
PlaySound(MAKEINTRESOURCE(IDR_WAVE1), AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC );
2. Is the IDR_WAVE1 correct ID? Or it looks like the text "IDR_WAVE1"?
In latter case you must not use MAKEINTRESOURCE macro - just:
Code:
PlaySound("IDR_WAVE1", AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC );
Re: sndPlaySound Wont play
Quote:
Originally Posted by
VictorN
Well, it is obvious that the "current working directory" might be not the same as the one containing "BELLS.wav" file.
You have to pass in the full pathe name to the
PlaySound call.
1. Of course, it is wrong. And it cannot just compile!
You forgot the second parameter that must be the
handle to the executable file that contains the resource to be loaded.
The correct call should look like:
Code:
PlaySound(MAKEINTRESOURCE(IDR_WAVE1), AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC );
2. Is the
IDR_WAVE1 correct ID? Or it looks like the text "IDR_WAVE1"?
In latter case you must not use MAKEINTRESOURCE macro - just:
Code:
PlaySound("IDR_WAVE1", AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC );
I tryed that and none of them worked.
Maybe is me trying to play the sound in my .dll
Ok playsound will not work in my .dll for nothing
PlaySound("C:\\BELLS.wav", NULL, SND_FILENAME);
but this works
sndPlaySound ("C:\\BELLS.wav",SND_LOOP|SND_ASYNC)
how do I use sndPlaySound to play a sound from my resources
Here is was my resource script file looks like
////////////////////////////HL2.rs///////////////////////
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// WAVE
//
IDR_WAVE1 WAVE "BELLS.wav"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
here is what my resource.h looks like
/////////////////////resource.h///////////////////////
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by HL2.rc
//
#define IDR_WAVE1 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40002
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
here is what my code looks like
Im trying to do all this in a .dll not an .exe
http://img19.picoodle.com/img/img19/...em_040fb11.jpg
Srry for the slopy post I dont see a code block option on the post
[code/] [code]
Re: sndPlaySound Wont play
Quote:
Originally Posted by
rentagoth
...
Im trying to do all this in a .dll not an .exe
What type of dll? Is it an MFC dll or not? If MFC - is it a regular or estension dll?
How are you using this dll?
Re: sndPlaySound Wont play
Quote:
Originally Posted by
VictorN
What type of dll? Is it an MFC dll or not? If MFC - is it a regular or estension dll?
How are you using this dll?
My Use of MFC is set to Use Standard Windows Libraries
Re: sndPlaySound Wont play
And what about:
PlaySound(_T(".Default"),NULL, SND_APPLICATION|SND_NODEFAULT);
this will play default bell sound in windows.
Re: sndPlaySound Wont play
Quote:
Originally Posted by
rentagoth
My Use of MFC is set to Use Standard Windows Libraries
Sorry, but I couldn't understand what you meant. :sick:
Re: sndPlaySound Wont play
Quote:
Originally Posted by
rentagoth
... Im trying to do all this in a .dll not an .exe
And would the same code work if you placed it in the exe?
Re: sndPlaySound Wont play
Quote:
Originally Posted by
VictorN
And would the same code work if you placed it in the exe?
this is that code that worked in the .exe
PlaySound("BELLS.WAV", NULL, SND_ASYNC);
It play the bells.wave from where the .exe is
Re: sndPlaySound Wont play
Quote:
Originally Posted by
rentagoth
this is that code that worked in the .exe
PlaySound("BELLS.WAV", NULL, SND_ASYNC);
It play the bells.wave from where the .exe is
Well, if this code does work being in exe and does NOT work being in dll then 99.9% that the problem is in your dll.
Therefore I already asked you but haven't got an answer:
Quote:
Originally Posted by
VictorN
What type of dll? Is it an MFC dll or not? If MFC - is it a regular or estension dll?
How are you using this dll?
Note, that if it is an MFC regular dll then you have to add
Code:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
to the beginning of the exported functions. See MSDN for details
Re: sndPlaySound Wont play
Nvm I just gave up on it
Thank you for your help =)
much appreciated