1 Attachment(s)
QSound problem playing different wav files
Hello,
I need to play a wav file when pressing a button. Its quite simple with QSound, but I have a problem with playing more then one wav file on Linux.
Example:
Code:
#ifndef SOUND_H
#define SOUND_H
#include <QPushButton>
#include <QHBoxLayout>
#include <QWidget>
#include <QSound>
{
Q_OBJECT
public slots:
void playError();
void playOk();
public:
foo();
};
#endif
Code:
#include <QApplication>
#include "sound.h"
foo::foo()
{
connect(button, SIGNAL(clicked()), this, SLOT(playOk()));
connect(button2, SIGNAL(clicked()), this, SLOT(playError()));
layout->addWidget(button);
layout->addWidget(button2);
m_error
= new QSound("err.wav");
m_ok
= new QSound("done.wav");
}
void foo::playError() { m_error->play(); }
void foo::playOk() { m_ok->play(); }
int main(int argc, char *argv[])
{
foo* bar = new foo();
bar->show();
return app.exec();
}
When I press ok button (even more then one), I can play wav file without a problem. But when I press one button (sound play) and then press second button it doesn't play the file. After it it doesn't play the file even on first button. It doesn't work for me on linux (gentoo, 2.6.29, nas installed). I haven't this problem on windows machine..What I am missing ?
Thanks for help
Re: QSound problem playing different wav files
Did you try using the static member QSound::play() instead?
Re: QSound problem playing different wav files
I'd say the problem might be in your linux system (or in NAS to be exact). I'd suggest using Phonon instead, it's much more reliable.
Re: QSound problem playing different wav files
Quote:
Originally Posted by
wysota
I'd say the problem might be in your linux system (or in NAS to be exact). I'd suggest using Phonon instead, it's much more reliable.
A little bit offtopic (sorry), but since you mentioned Phonon...do you know if it is possible to pass wav files to Phonon as resource files? I tried this once with QSound and failed miserably.
Re: QSound problem playing different wav files
Quote:
Originally Posted by
victor.fernandez
yes I did. same result :(
Quote:
Originally Posted by
wysota
I'd say the problem might be in your linux system (or in NAS to be exact). I'd suggest using Phonon instead, it's much more reliable.
I wanted to stay away of phonon. I always have a problem with installation on windows etc but it looks like I have to use it :/
Thanks all..
Re: QSound problem playing different wav files
Quote:
Originally Posted by
Kumosan
do you know if it is possible to pass wav files to Phonon as resource files?
It should work with Phonon. As far as I remember you can pass any QIODevice to it, even a network socket.
Re: QSound problem playing different wav files
Tried today after upgrade nas to 1.9.2 and everything is working..