|
도움말에서 조금 찾아보니까요...다음과 같은 내용이 있네요.
Wait프로퍼티를 true로 하면은 플레이 함수 호출하고 플레이 중일때는 제어권을 프로그램으로 돌려 주지 않고 false로 하면 단 한번만 사운드가 플레이 된다는 그런 내용 같습니다.
그래서 저도 도움말의 예제랑 비슷하게 해봤는데 sleep함수 사용 안하면 귀에 들리는거는 두번 정도 플레이 되는걸로 들리네요...아마도 너무 빨리 플레이가 되서 못듣는거 같습니다.
int i;
MediaPlayer1->Hide();
MediaPlayer1->FileName = "C:\\winnt\\media\\경고 메시지(꿈의 소리).WAV";
MediaPlayer1->AutoRewind = true;
MediaPlayer1->Open(); // Open the media player
MediaPlayer1->Wait = true; // don't return until playing is done
for(i=0; i<10 ; i++)
{
MediaPlayer1->Play(); // Play sound
//Sleep(3000);
}
-도움말에서 찾은 내용-
The following code plays a .WAV audio file named NI!.WAV twice. The first call to play doesn't return control to the application until the file is done playing. Note that if you remove the line of code that sets wait to true, the sound is only played once.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
MediaPlayer1->FileName = "ni!.wav";
MediaPlayer1->AutoRewind = true;
MediaPlayer1->Open(); // Open the media player
try
{
MediaPlayer1->Wait = true; // don뭪 return until playing is done
MediaPlayer1->Play(); // Play sound
MediaPlayer1->Play(); // Play again after first play is completed
}
__finally
{
MediaPlayer1->Close(); // Close media player
}
}
틀린점 있으면 고쳐주세요..^^
통일바라기 님이 쓰신 글 :
:
: 늘 고수님들의 도움으로 한걸음 한걸은 나가고 있는 초짜입니다.
:
: 아래 소스와 같이 조건에 따라 'k'값이 0과 1로 변하게 되고 'k'값이 1이 되면
: bikebell.wav 파일을 실행하게 되어 있습니다.
:
: 제가 구현하고 싶은 것은 우선 k=1이 되었을때, bikebell.wav 파일을 무한루프로
: 돌려 실행을 시키는데, 도중에 사용자로부터 입력이 들어오면(예로 TForm1에 마우스
: 를 클릭하는 방법, 또는 버튼을 클릭하는 방법) 무한루프에서 빠져나오는 것입니다.
:
: 또, 주석문의 for 문을 실행시키면 10번 동안 bikebell.wav 파일이 수행되어야 할
: 것 같은데 왜 1번만 수행되는지 모르겠습니다.
:
: 미리 답변에 감사드립니다.
:
: ... 전략 ...
:
: for (j=0; j < Temp_List1->Count ; j++)
: k = k*l[j];
:
: if (k ==1) {
: ListBox5->Items->Add(Temp_List2->Strings[i]);
: ListBox6->Items->Add(Temp_List2->Strings[i]);
: // for(i=0; i<10 ; i++) {
: MediaPlayer1->Hide();
: MediaPlayer1->FileName = "D:\\Ironwill\\bikebell.wav";
: MediaPlayer1->Open(); // Open the media player
: MediaPlayer1->Play(); // Play sound
: // }
: }
:
: ... 후략 ...
:
:
|