4099aol
asked on
Play a wav file 5 times???
I currently use PlaySound ("reg.wav", 0, SND_ASYNC); to play a wav file, but it only plays it once. How can I get it to play the sound 5 times?? If I do this...
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
It plays them all at once, and sounds very bad.
thanks
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
PlaySound ("reg.wav", 0, SND_ASYNC);
It plays them all at once, and sounds very bad.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
// add some kind of delay here
// it can either be a time delay for
// 5*the length of the reg.wav
// ,it can be opening of dialog box
// or it can show a opening screen of a program
// For example Call funcation 'Sleep(1000)'; to play the wave // // file for one second
PlaySound (NULL, 0, 0);
The first Playsound statement opens the wav file and start playing, loops if nessesary. The line PlaySound(NULL, 0, 0) stops it
// add some kind of delay here
// it can either be a time delay for
// 5*the length of the reg.wav
// ,it can be opening of dialog box
// or it can show a opening screen of a program
// For example Call funcation 'Sleep(1000)'; to play the wave // // file for one second
PlaySound (NULL, 0, 0);
The first Playsound statement opens the wav file and start playing, loops if nessesary. The line PlaySound(NULL, 0, 0) stops it
ASKER
So i do this??
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
Sleep(1000)
PlaySound (NULL, 0, 0);
But wouldn't that make it pause even more?? I want it to not pause at all..
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
Sleep(1000)
PlaySound (NULL, 0, 0);
But wouldn't that make it pause even more?? I want it to not pause at all..
No, this would not pause it at all.
You are looking at the difference between SND_ASYNC
and SND_SYNC
Sleep(1000);
This will only let you play the wav file for one second
if you want to play for 3 seconds, you would write
Sleep(3000);
You are looking at the difference between SND_ASYNC
and SND_SYNC
Sleep(1000);
This will only let you play the wav file for one second
if you want to play for 3 seconds, you would write
Sleep(3000);
ASKER
ohh ok, so it will play the sound over and over and over again until the sleep is over??
thanks
thanks
Exactly!
Are you still getting the pause?
Are you still getting the pause?
ASKER
thanks I set it for 2500 (2.5 seconds) it works just fine. but now, after the sleep it locks up when it tries to create rgnum.dat, why??
try this instead
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
Sleep(2500)
PlaySound (NULL, 0, SND_LOOP+SND_ASYNC);
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
Sleep(2500)
PlaySound (NULL, 0, SND_LOOP+SND_ASYNC);
ASKER
ok that is not what is messing up, I commented out the whole sound thing (with //) and it still locked up. It is saying it can't create regnum.dat, could that it already exists??
comment out the line below
and see if you are still getting stuck.
or getting the out memory message.
MyStringList->SaveToFile(" regnum.dat ");
also, where is this regnum.dat located exactly.
and see if you are still getting stuck.
or getting the out memory message.
MyStringList->SaveToFile("
also, where is this regnum.dat located exactly.
ASKER
sorry I told you the wrong information.. it is locking up when it trys to add to user.dat. here is the ending of the shareware registration code validation ..
// This part ONLY runs if the reg code is correct
if (ValidationOk)
{
//Play reg sound
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
Sleep(2500);
PlaySound (NULL, 0, SND_LOOP+SND_ASYNC);
//Show a thanks for registering message
Application->MessageBox("T hank you for registering!!", "Validation", MB_OK);
// Put contents of Edit1 into regcd.dat
TStringList *MyStringList = new TStringList;
MyStringList->Add(Edit1->T ext);
MyStringList->SaveToFile(" regcd.dat" );
// Put contents of Edit2 into user.dat
TStringList *MyStringList1 = new TStringList;
MyStringList1->Add(Edit2-> Text);
MyStringList1->SaveToFile( "user.dat" );
}
delete[] Buffer;
}
what is wrong with it?????????
I think it is because user.dat already exists.
// This part ONLY runs if the reg code is correct
if (ValidationOk)
{
//Play reg sound
PlaySound ("reg.wav", 0, SND_LOOP+SND_ASYNC);
Sleep(2500);
PlaySound (NULL, 0, SND_LOOP+SND_ASYNC);
//Show a thanks for registering message
Application->MessageBox("T
// Put contents of Edit1 into regcd.dat
TStringList *MyStringList = new TStringList;
MyStringList->Add(Edit1->T
MyStringList->SaveToFile("
// Put contents of Edit2 into user.dat
TStringList *MyStringList1 = new TStringList;
MyStringList1->Add(Edit2->
MyStringList1->SaveToFile(
}
delete[] Buffer;
}
what is wrong with it?????????
I think it is because user.dat already exists.
ASKER
Sorry it was locking on regcd.dat.
Also I tried to have regcd.dat and user.dat before writting to it but it still locked up. Also for your reff I used int result = remove("user.dat"); to delete the files..
Also I tried to have regcd.dat and user.dat before writting to it but it still locked up. Also for your reff I used int result = remove("user.dat"); to delete the files..
Try this
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w")
fprintf(regcd, "%s", Edit1->Text);
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("regcd.dat", "a")
fprintf(user, "%s", Edit2->Text);
fclose(user);
-------------------------- ---------- ---------- ---
if above doesn't work try this
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w")
fprintf(regcd, "%s", (Edit1->Text).c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
regcd = fopen("regcd.dat", "a")
fprintf(user, "%s", (Edit2->Text).c_str());
fclose(user);
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w")
fprintf(regcd, "%s", Edit1->Text);
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("regcd.dat", "a")
fprintf(user, "%s", Edit2->Text);
fclose(user);
--------------------------
if above doesn't work try this
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w")
fprintf(regcd, "%s", (Edit1->Text).c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
regcd = fopen("regcd.dat", "a")
fprintf(user, "%s", (Edit2->Text).c_str());
fclose(user);
ASKER
I commented out the following codes and it worked fine...
// Put contents of Edit1 into regcd.dat
TStringList *MyStringList = new TStringList;
MyStringList->Add(Edit1->T ext);
MyStringList->SaveToFile(" regcd.dat" );
//Put contents of Edit2 into user.dat
TStringList *MyStringList1 = new TStringList;
MyStringList1->Add(Edit2-> Text);
MyStringList1->SaveToFile( "user.dat" );
So the error is in that code, could you please tell me what is wrong with it??
// Put contents of Edit1 into regcd.dat
TStringList *MyStringList = new TStringList;
MyStringList->Add(Edit1->T
MyStringList->SaveToFile("
//Put contents of Edit2 into user.dat
TStringList *MyStringList1 = new TStringList;
MyStringList1->Add(Edit2->
MyStringList1->SaveToFile(
So the error is in that code, could you please tell me what is wrong with it??
ASKER
I am trying it now...
ASKER
I used the first set of codes. THis popup message came up..
Project webmaste1.exe raised exception class EAcessViolation with message 'Acces violation at address 00444E60'. Read of address 007BD23C.
what ever all that means..
Project webmaste1.exe raised exception class EAcessViolation with message 'Acces violation at address 00444E60'. Read of address 007BD23C.
what ever all that means..
ASKER
The second set codes comes up with the same error message...
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w")
fprintf(regcd, "%s", (Edit1->Text).c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a")
fprintf(user, "%s", (Edit2->Text).c_str());
fclose(user);
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w")
fprintf(regcd, "%s", (Edit1->Text).c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a")
fprintf(user, "%s", (Edit2->Text).c_str());
fclose(user);
ASKER
same error message...
what if you put in only these three lines
FILE *regcd;
regcd = fopen("regcd.dat", "w")
fclose(regcd);
FILE *regcd;
regcd = fopen("regcd.dat", "w")
fclose(regcd);
Also try this
// Put contents of Edit1 into regcd.dat
AnsiString S(Edit1->Text)
TStringList *MyStringList = new TStringList;
MyStringList->Add(S);
MyStringList->SaveToFile(" regcd.dat" );
// Put contents of Edit2 into user.dat
AnsiString S2(Edit2->Text)
TStringList *MyStringList1 = new TStringList;
MyStringList1->Add(S2);
MyStringList1->SaveToFile( "user.dat" );
// Put contents of Edit1 into regcd.dat
AnsiString S(Edit1->Text)
TStringList *MyStringList = new TStringList;
MyStringList->Add(S);
MyStringList->SaveToFile("
// Put contents of Edit2 into user.dat
AnsiString S2(Edit2->Text)
TStringList *MyStringList1 = new TStringList;
MyStringList1->Add(S2);
MyStringList1->SaveToFile(
ASKER
FILE *regcd;
regcd = fopen("regcd.dat", "w")
fclose(regcd);
works, but how does it know which editbox to look at??
regcd = fopen("regcd.dat", "w")
fclose(regcd);
works, but how does it know which editbox to look at??
So, we know it's
the line
fprintf(regcd, "%s", (Edit1->Text).c_str());
that is causing the error
the line
fprintf(regcd, "%s", (Edit1->Text).c_str());
that is causing the error
ASKER
guess so, but the three lines of codes work. The only problem with it is that I do not know how to get it to work with both Edit1 and Edit2
Try this again
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w");
AnsiString S(Edit1->Text);
fprintf(regcd, "%s", S.c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a");
AnsiString S2(Edit2->Text);
fprintf(user, "%s", S2.c_str());
fclose(user);
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w");
AnsiString S(Edit1->Text);
fprintf(regcd, "%s", S.c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a");
AnsiString S2(Edit2->Text);
fprintf(user, "%s", S2.c_str());
fclose(user);
ASKER
nope same error message....
Hi 4099aol,
I think I find the problem
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w");
AnsiString S(Edit1->Text);
fprintf(regcd, "%s", S->c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a");
AnsiString S2(Edit2->Text);
fprintf(user, "%s", S2->c_str());
fclose(user);
I think I find the problem
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w");
AnsiString S(Edit1->Text);
fprintf(regcd, "%s", S->c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a");
AnsiString S2(Edit2->Text);
fprintf(user, "%s", S2->c_str());
fclose(user);
hi 4099aol
Just want to let you know, you can obtain the complete
documentation on Borland Builder at
http://www.borland.com/techpubs/bcppbuilder/
The documentation is approximately 30MB.
Just want to let you know, you can obtain the complete
documentation on Borland Builder at
http://www.borland.com/techpubs/bcppbuilder/
The documentation is approximately 30MB.
ASKER
[C++ Error] Options.cpp(351): Pointer to structure required on left side of -> or ->*.
[C++ Error] Options.cpp(357): Pointer to structure required on left side of -> or ->*.
[C++ Warning] Options.cpp(362): 'S2' is assigned a value that is never used.
[C++ Error] Options.cpp(357): Pointer to structure required on left side of -> or ->*.
[C++ Warning] Options.cpp(362): 'S2' is assigned a value that is never used.
ASKER
i will check it out now!
Try this
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w");
fprintf(regcd, "%s", (Edit2->Text)->c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a");
fprintf(user, "%s", (Edit2->Text)->c_str());
fclose(user);
FILE *regcd;
FILE *user;
// Put contents of Edit1 into regcd.dat
regcd = fopen("regcd.dat", "w");
fprintf(regcd, "%s", (Edit2->Text)->c_str());
fclose(regcd);
// Put contents of Edit2 into user.dat
user = fopen("user.dat", "a");
fprintf(user, "%s", (Edit2->Text)->c_str());
fclose(user);
ASKER
same error message...
4099aol, it's time to finish off this question.
#include <vcl\sysutils.hpp>
int regcd;
int user;
AnsiString f1name("regcd.dat");
// Put contents of Edit1 into regcd.dat
regcd = FileOpen(f1name, fmOpenWrite);
FileWrite(regcd, (char*)((Edit1->Text).c_st r()), sizeof((Edit1->Text).c_str ()));
FileClose(regcd);
AnsiString f2name("user.dat");
// Put contents of Edit2 into user.dat
user = FileOpen(f2name, fmOpenWrite);
FileWrite(user, (char*)((Edit2->Text).c_st r()),
sizeof((Edit2->Text).c_str ()));
FileClose(user);
#include <vcl\sysutils.hpp>
int regcd;
int user;
AnsiString f1name("regcd.dat");
// Put contents of Edit1 into regcd.dat
regcd = FileOpen(f1name, fmOpenWrite);
FileWrite(regcd, (char*)((Edit1->Text).c_st
FileClose(regcd);
AnsiString f2name("user.dat");
// Put contents of Edit2 into user.dat
user = FileOpen(f2name, fmOpenWrite);
FileWrite(user, (char*)((Edit2->Text).c_st
sizeof((Edit2->Text).c_str
FileClose(user);
ASKER
thanks.
ASKER