-
September 15th, 2012, 11:30 AM
#1
Qt c++ play sound on key press - stops working after a few seconds
I'm making an apllication which needs to play .wav file when user type something inside QTextEdit. I made some code but after minute or less the sound stops, so I made silly workarround. After 30 clicks I invoke sound->stop(); and then the loop start again, that works, but it's not good, can you give better solution. Here is my code:
Code:
int count = 0;
bool MainWindow::eventFilter(QObject *o, QEvent *e){
if(e->type() == QEvent::KeyPress)
{
tipka->play();
tipka->seek(0);
count++;
if(count == 30){
tipka->pause();
count = 0;
}
}
return false;
}
(tipka is Phonon::MediaObject)
-
September 16th, 2012, 01:24 PM
#2
Re: Qt c++ play sound on key press - stops working after a few seconds
what do you want to do?
is it short beep that occurs when the user presses a key, or a longer one?
you cant seek when the sound is in the stopped state, try omitting the seek(0) or use stop() instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|