Because I whim I self-study before computer technology to the whole charge for auxiliary out general function is on the charging interface by pressing "+" at the time of charging time deal successfully with my assistant to prompt the patient should pay RMB XXXXXX (implementation) play sound files, so here I was thinking about specific keyboard hook code I will not write
On the function of about the same but still some small bugs don't know how to deal with general situation described as follows:
While I press the + sign to start a thread broadcast voice said if I accidentally press the consecutive two + will play "the should pay XXXX" voice will appear in my EXE overlap can realize thread synchronization but is in the keyboard hook callback function has been don't know how to synchronize my baidu consecutive days without any result so I came here to look at Daniel great god can give the answer or way of thinking and a little because I haven't touched the programming for eight years when the cashier has learned knowledge waste a lot of so Daniel great spirit in answer, they don't say but as the saying goes, scribble gang brought what Buddha the most detailed solution given to the west as much as possible,
I was so tired I haven't been sleeping for more than 20 hours thank you!!!!!!
CodePudding user response:
Threads play media, lane is bad to can cause crashes, thread stagnation, false close such as fault, if you want to force a thread, to use the API function,Suggestion:
http://blog.csdn.net/jankercsdn/article/details/8874469
Another: in view of the fact that you play, there is only one WAV, there is no parallel play, suggest that you did not use a thread to try and direct control of a media player MediaPlayer control, (or) directly using playSound function when duplicate gesture, first close the media, to play, it is more convenient,
Also can use third-party control, such as multimedia function library Bass. DLL, please refer to http://www.cnblogs.com/del/category/150851.html
CodePudding user response:
Control of your own, 5 seconds not repeat play ahCodePudding user response:
Two schemes, the optional1. If the old thread didn't end, a new playing thread won't play
2. If the old thread not over, stop, and then play the new
CodePudding user response:
Do a mutex oneself use Semaphore, prevent broadcast reentrant,CodePudding user response:
Try to use critical regionACriticalSection. Enter;
Try
PlaySound ();//here with synchronous broadcasting SND_SYNC
The finally
ACriticalSection. Leave;
end;
CodePudding user response:
Don't put the thread object defined as a local variable, defined as global, every time play, there does not exist, to judge the global thread variables can be controlledCodePudding user response:
The eldest brother say so many I still don't understandI said the general framework under the
The function keyd (... ) : a DWORD; Stdcall;//keyboard hook callback function
The begin
If (wp=vk_ADD) and (SHL 31 (1) and lp=0)
Then
Beginthread (nil, 0, @ play, nil, 0, Threadhandle);//play music music is composed of 20 WAV files
end;
CodePudding user response:
Ah, I give who can help me to complete the project file?CodePudding user response:
Not said the don't use a thread to PLAY with you, saying I also seen WAVE function, can PLAY this movement is a surrender to all of the need to PLAY the cache, it is not necessary to use threadsCodePudding user response:
To, do not use thread, using PlaySound, specify SND_SYNC marks won't overlap played,