Results 1 to 1 of 1

Thread: Sound not playing when using executable file

  1. #1
    Join Date
    Nov 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Sound not playing when using executable file

    Hi everyone,

    I've been travelling between posts and documentation but haven't found a solution for the following problem.

    I'm using Netbeans under Ubuntu and Qt 4.7.1.

    I'm doing a small alarm clock application and having some problems with the sound.

    When I compile and run from Netbeans, the sound works, but not when I run the executable file outside Netbeans.

    I had the same problem with some images but it got fixed by using a resource file.

    Here is my resource file :

    Qt Code:
    1. <!DOCTYPE RCC><RCC version="1.0">
    2. <qresource>
    3. <file>icons/up_arrow.png</file>
    4. <file>icons/down_arrow.png</file>
    5. <file>sounds/alarm_clock.wav</file>
    6. </qresource>
    7. </RCC>
    To copy to clipboard, switch view to plain text mode 

    And here is how I play a sound using Phonon :

    Qt Code:
    1. Phonon::MediaObject *music;
    2.  
    3. music = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource("sounds/alarm_clock.wav"));
    4. music->play();
    To copy to clipboard, switch view to plain text mode 

    Any help would be appreciated.


    Added after 10 minutes:


    Ok solution found

    For those who might face this problem, here it goes;

    Adding ":/" solves the problem :

    Qt Code:
    1. music = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(":/sounds/alarm_clock.wav"));
    To copy to clipboard, switch view to plain text mode 

    Should have read further... Sorry.
    Last edited by Zotop; 25th November 2010 at 23:47.

Similar Threads

  1. Replies: 5
    Last Post: 30th August 2011, 23:21
  2. Replies: 5
    Last Post: 15th June 2010, 07:42
  3. playing a mp3 file ?
    By hcetiner in forum Newbie
    Replies: 1
    Last Post: 13th May 2010, 10:21
  4. Asynchronously playing a sound (.wav) on windows mobile
    By TMan in forum Qt for Embedded and Mobile
    Replies: 10
    Last Post: 20th October 2008, 19:16
  5. Getting sound data from a wave file
    By ko9 in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 11:23

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.