Results 1 to 5 of 5

Thread: QSound simply doesn't work

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QSound simply doesn't work

    Hello!

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

    It call it normally:

    Qt Code:
    1. sound = new QSound("./alarm1.wav",this);//getting the audio file
    2. sound->setLoops(3);//three times that specific audio file is played
    3. sound->play();
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QSound simply doesn't work

    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?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSound simply doesn't work

    Quote Originally Posted by Talei View Post
    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

  4. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QSound simply doesn't work

    AFAIK is acronym for "as far as i know"
    Did You try:
    Qt Code:
    1. sound = new QSound("/home/martin/Documentos/Programas Qt/M/mClock/mClock 1.4/alarm1.wav",this);
    To copy to clipboard, switch view to plain text mode 
    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?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  5. #5
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSound simply doesn't work

    Quote Originally Posted by Talei View Post
    AFAIK is acronym for "as far as i know"
    Did You try:
    Qt Code:
    1. sound = new QSound("/home/martin/Documentos/Programas Qt/M/mClock/mClock 1.4/alarm1.wav",this);
    To copy to clipboard, switch view to plain text mode 
    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

Similar Threads

  1. Screenshot example doesn't work on Mac OSX
    By Damiano in forum Qt Programming
    Replies: 0
    Last Post: 19th January 2011, 11:17
  2. autoScale doesn't work
    By Braunstein in forum Qwt
    Replies: 4
    Last Post: 12th November 2010, 18:22
  3. Slot doesn't seem to work
    By waynew in forum Newbie
    Replies: 3
    Last Post: 10th November 2009, 09:54
  4. cant make QSound work
    By akon in forum Newbie
    Replies: 8
    Last Post: 19th March 2009, 15:34
  5. QThread doent work for QSound
    By anafor2004 in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2008, 16:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.