|
for (i=0; i < Temp_List2->Count; i++) {
k=1;
for(j=0; j < Temp_List1->Count; j++) {
if(Temp_List2->Strings[i] == Temp_List1->Strings[j])
{ l[j] = 0; }
else
{ l[j] = 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]);
}
}
if (k ==1) {
MediaPlayer1->Hide();
MediaPlayer1->FileName = "D:\\Ironwill\\bikebell.wav";
// MediaPlayer1->AutoRewind = true;
MediaPlayer1->Open(); // Open the media player
// MediaPlayer1->Wait = true; // don't return until playing is done
for(int i_count=0; i_count<3 ; i_count++) {
MediaPlayer1->Play(); // Play sound
Sleep(5000);
}
}
위와 같습니다.
k=0이 되고, ListBox5/6에 Add가 되지 않고 Wave 파일도 실행이 안되게 구현했으며,
k=1이 되면 ListBox5/6에 Add 시키고 Wave 파일도 실행이 되도록...
처음에는 Wave 파일이 실행되는 라인도 For 루프에 포함을 시켰다가 따로 빼보기도
했는데 위와 같이 하면 Wait/AutoRewind 프로퍼티와 관계없이 3번 실행됩니다만,
선행되어야 하는 ListBox5/6에는 아무것도 나오지 않고 제어도 할 수 없는 상황이
됩니다.
Wave 파일을 3번 수행하고 나서야 ListBox5/6에 보여지고 제어권도 돌려줍니다.
그리고, 제가 구현하고 싶은 것은 (처음에도 올렸지만) 버튼등을 이용하여 실행을
중단하고자 하는 것입니다.
하여튼 관심가져 주셔서 감사합니다.
(그런데, 도움말을 찾아봐도 안보이던데요... 제가 4.0 버젼이라 그런지 몰라도...)
윤구 님이 쓰신 글 :
: 도움말에서 조금 찾아보니까요...다음과 같은 내용이 있네요.
: 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
: : // }
: : }
: :
: : ... 후략 ...
: :
: :
|