PDA

View Full Version : QSound simply doesn't work



Momergil
2nd September 2011, 15:33
Hello!

I'm having a problem in using QSound; it simply doesn't work.

It call it normally:


sound = new QSound("./alarm1.wav",this);//getting the audio file
sound->setLoops(3);//three times that specific audio file is played
sound->play();

and the slot were this code is set is called by a signal, connected by a connect() in the appropriate time.

I already verify that the connection is OK. The isAvaliable() function returns true. The name of the file is correct, and it is in the same directory of the executable. But the sound simply doesn't work.

There is no message in the Debugger that tells something. The anything wrong that states when I run it is:


&"warning: GDB: Failed to set controlling terminal: Argumento inv\303\241lido\n"

But it doesn't seems to have any connection with the QSound problem (in fact, if somebody knows what this debug message is saying, I would like to know that as well!).

Could somebody help, please?


Thanks!


Momergil

Talei
2nd September 2011, 15:53
Problem probably lies in current working directory set by the QtCreator, with AFAIK (I had in past same problem) is diffrent then actual directory where bin is, use qDebug() << QDir::currentPath() to see what the working path is.

I tested Your code and it worked fine.
Try using full path i.e. /home/user/program/qt/program/sound.wav.
See if this file plays in external/native player if not install appropriate codecs.

AFAIK Error is related to the debugger, did You installed it?

Momergil
2nd September 2011, 18:50
Problem probably lies in current working directory set by the QtCreator, with AFAIK (I had in past same problem) is diffrent then actual directory where bin is, use qDebug() << QDir::currentPath() to see what the working path is.

I tested Your code and it worked fine.
Try using full path i.e. /home/user/program/qt/program/sound.wav.
See if this file plays in external/native player if not install appropriate codecs.

AFAIK Error is related to the debugger, did You installed it?


Hello Talei and thanks for the reply.

First I have no idea of what AFAIK or AFAIK Error is. Could you please say what you are talking about?

Second, I did put the entire path as you indicated, using the "qDebug() << QDir::currentPath()", and it still doesn't work. Could empty spaces be the problem? The file is in: "/home/martin/Documentos/Programas Qt/M/mClock/mClock 1.4/alarm1.wav".


Thanks once again!


Momergil

Talei
2nd September 2011, 20:08
AFAIK is acronym for "as far as i know"
Did You try:

sound = new QSound("/home/martin/Documentos/Programas Qt/M/mClock/mClock 1.4/alarm1.wav",this);
also put it in constructor of the class to be sure that the code is executed.
Did You try playing it in external sound player, is this valid .wav file?

Momergil
2nd September 2011, 21:12
AFAIK is acronym for "as far as i know"
Did You try:

sound = new QSound("/home/martin/Documentos/Programas Qt/M/mClock/mClock 1.4/alarm1.wav",this);
also put it in constructor of the class to be sure that the code is executed.
Did You try playing it in external sound player, is this valid .wav file?

Hello Talei,

About the AFAIK, sorry, my english is not good when it comes about such acronyms! =]

Yes, I did put that code exactly, and it didn't work again.

Yes, I did play with an external sound player, and it worked fine. I did put the code in the constructor, nothing happened once again.

Thanks,

Momergil