Results 1 to 5 of 5

Thread: not able to use QSound to play wave file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    60
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default not able to use QSound to play wave file

    Dear All,

    I want to play wave file in my application using Qt libraries 4.6.2.

    I use the below code, i am calling QSound to play wave file placed in "/home/sky/1.wav" in button press event,however it doesn't work for me.can any one suggest the correct way to use.

    The system shows that the sound facility is available.

    Qt Code:
    1. void Widget::on_pushButton_clicked()
    2. {
    3.  
    4. if(QSound::isAvailable ())
    5. printf("Sound Facility is available\n");
    6. else
    7. printf("Sound Facility is not available\n");
    8. QSound bells("/home/sky/1.wav");
    9. bells.play();
    10. //QSound::play("/home/guest/QtTest/image_viewer/1.wav");
    11. printf("Inside push Button\n");
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: not able to use QSound to play wave file

    It might be that QSound just doesn't work on your particular platform, for whatever reason.
    You may need / want to check whether Phonon would:
    http://developer.qt.nokia.com/doc/qt...-overview.html

    (I remember QSound not working in Maemo and having to use Phonon.)

  3. #3
    Join Date
    Apr 2009
    Location
    Italy
    Posts
    70
    Thanks
    23
    Thanked 15 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: not able to use QSound to play wave file

    Funny, I was about to write:
    "You are creating the QSound on the stack, so the sound is supposed to stop when the block exits."

    but I just tested it on Windows and it plays anyway (mmh, isn't the destructor supposed to call stop()?) Nonetheless, that might be the problem on your specific platform.

    Also, if you are working on a mobile platform, check out the new QtMultimedia module in QtMobility.

  4. #4
    Join Date
    Nov 2009
    Posts
    60
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: not able to use QSound to play wave file

    Thanks for the response.

    I tried the static call QSound:lay("/home/sky/1.wav"),still I am facing the same issue,

    Please note,I am using Qt on Embedded platform.

    Regards,

    Ratheendran

  5. #5
    Join Date
    Jun 2012
    Location
    Paris, France
    Posts
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: not able to use QSound to play wave file

    QSound on Windows is based on blocking PlaySound() interface, which is not interruptible. So a deleted QSound object will still play to the end (an internal cleanup daemon will take care of it once it has been played).
    On platforms with a less convoluted implementation, the sound will be cut as soon as you delete the QSound object. So if you create a QSound instance as a local variable, you will barely hear a click before the function terminates and the destructor cuts off your sound.

Similar Threads

  1. QSound can not play immediately
    By thanhluanbk88 in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2011, 09:16
  2. Replies: 0
    Last Post: 2nd March 2011, 08:36
  3. QSound Play error
    By augusbas in forum Qt Programming
    Replies: 0
    Last Post: 1st February 2010, 05:57
  4. QSound don't play wav in qtopia 1.5.4, 1.7.0 and 2.2.0
    By alexandr in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 30th January 2007, 19:05
  5. Replies: 1
    Last Post: 7th July 2006, 10:14

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
  •  
Qt is a trademark of The Qt Company.