×

Discussion Board

Results 1 to 14 of 14

Thread: How to QSound ?

  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Location
    Southpark
    Posts
    71

    How to QSound ?

    #include <QSound>

    QSound* acknowledge = new QSound("Acknowledge.wav");
    acknowledge->play();


    LOVE QT for its simplicity.

    Now...just one problem.
    It doesn't work on the emulator AND the phone.
    Where to place the file in the emulator ?

    And how to tell Carbide to include the sound file when compiling for the phone release so that this code will work ?

  2. #2
    Nokia Developer Moderator
    Join Date
    May 2007
    Posts
    468

    Re: How to QSound ?

    Install it to f.ex c:\\data folder (define that in .pro file, see http://library.forum.nokia.com)

    refer to as
    QSound:lay("c:\\data\\krlaugh.wav");

    Jack

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Posts
    468

    Re: How to QSound ?

    Another, easier way is to have it in Qt resources, then you refer to it as
    QSound :: play (":/prefix/finame.wav")

    See http://doc.trolltech.com/4.6/resources.html

    Jack

  4. #4
    Regular Contributor
    Join Date
    Feb 2009
    Location
    Southpark
    Posts
    71

    Re: How to QSound ?

    Quote Originally Posted by Jack Torrance
    Install it to f.ex c:\\data folder (define that in .pro file, see http://library.forum.nokia.com)

    refer to as
    QSound:lay("c:\\data\\krlaugh.wav");
    How do you install it in c:\\data folder ?
    You then refer me to the documentation without any specific link...
    Dude...
    You could have just show me an example of the *.pro file to do that right ?
    That one line of code ?
    What's with the whole "See the documentary" thing ?


    Dude, QT resources cannot include sound files

  5. #5
    Nokia Developer Moderator
    Join Date
    May 2007
    Posts
    468

    Re: How to QSound ?

    Dude,
    do keep in mind that no one here gets paid for helping you so if you want someone answering your questions recheck the attitude.

    You're right that I could code you a working example if I'd have the time.

    What it comes to the direct link to your problem in some cases it's good to read the whole documentation and learn while doing it.

    Jack

  6. #6
    Regular Contributor
    Join Date
    Feb 2009
    Location
    Southpark
    Posts
    71

    Re: How to QSound ?

    I even set the path DIRECTLY
    and it still doesn't work:


    QSound* b = new QSound("C:\\Symbian\\Carbide\\workspace\\a2\\sound.wav");
    b->play();


    I proceed to edit the pkg file:
    "Sound.wav" -"!:\private\E5C48996\Sound.wav"
    and do:
    QSound* b = new QSound("Sound.wav");
    b->play();

    Still nothing....nothing I say...
    Last edited by eric_cartman; 2009-12-10 at 19:04.

  7. #7
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: How to QSound ?

    Quote Originally Posted by eric_cartman View Post
    I even set the path DIRECTLY
    and it still doesn't work:


    QSound* b = new QSound("C:\\Symbian\\Carbide\\workspace\\a2\\sound.wav");
    b->play();
    I think you have to change the path. You are giving a path "C:\\Symbian\\Carbide\\workspace\\a2\\sound.wav" which is path of your PC's c: while you are require the .wav file in to the emulator's c:.

    Anyone can correct this if i am wrong.
    Jajal Mehul

  8. #8
    Regular Contributor
    Join Date
    Feb 2009
    Location
    Southpark
    Posts
    71

    Re: How to QSound ?

    Dude, you are going the right track !

    I go to the *.pkg file and retrieve the ID: E5C48996.
    I do a search retrieved this path:
    C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\private\e5c48996

    After I copied the sound to that folder, the sound played!
    It finally respect my authoritah !

    Now the next question is
    There is a2_template.pkg and a2.pkg [haiz........]

    I tried to add in:
    "Sound.wav" -"!:\private\E5C48996\Sound.wav"


    and

    "C:\Symbian\Carbide\workspace\a2\Sound.wav" -"!:\private\E5C48996\Sound.wav"

    I even tried:


    "C:\\Symbian\\Carbide\\workspace\\a2\\Sound.wav" -"!:\private\E5C48996\Sound.wav"


    Yet it doesn't copy!
    The sound will play but only after I MANUALLY copy the *.wav file into:
    C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\private\e5c48996
    myself.

    Lame....
    The *.pkg file doesn't respect my authoritah !










    I EVEN tried to access the *.pro file:
    TEMPLATE = app
    TARGET = a2
    QT += core \
    gui
    HEADERS += a2.h
    SOURCES += a2_reg.rss \
    main.cpp \
    a2.cpp\
    Sound.wav
    FORMS += a2.ui
    RESOURCES +=
    symbian:TARGET.UID3 = 0xE5C48996

    and add the Sound.wav there.
    It doesn't respect my authoritah !

  9. #9
    Nokia Developer Moderator
    Join Date
    May 2007
    Posts
    468

    Re: How to QSound ?

    pkg file is for making a sis package. sis package is installed to a device, it has no affect on the emulator...

    cheers,
    Jack

  10. #10
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: How to QSound ?

    Hi,

    If you want to export files from your project into the emulator directory structure, you can use BLD_INF_RULES.prj_exports in your .pro file.

    See CS001423 - Exporting files into the emulator environment in Qt for Symbian

  11. #11
    Registered User
    Join Date
    Jan 2008
    Posts
    29

    Re: How to QSound ?

    The .pkg file is generated by qmake (see first lines of comment in the file). Editing it will have not effect, since it is overwritten at the next build.

    Use the DEPLOYMENT keyword int your .pro file instead. See http://wiki.forum.nokia.com/index.ph...t_package_file for more info.

    As for the emulator have a look at: http://wiki.forum.nokia.com/index.ph...Qt_for_Symbian

    PS.: You might consider dropping "dude" next time.

  12. #12
    Regular Contributor
    Join Date
    Feb 2009
    Location
    Southpark
    Posts
    71

    Re: How to QSound ?

    Ok DUDES I've figured it out:

    For those of you in the future that come to this forum to try and figure this whole QSound deployment out, here's the step by step:

    1: QSound does work for Symbian, no need for Symbian C++'s MMdaAudioPlayerCallback and crap.

    2: //Change the UID number accordingly.
    For the Simulator to work, in the *.pro file, right at the bottom, copy and paste

    symbian:
    {
    BLD_INF_RULES.prj_exports += \
    "Sound.wav ..\winscw\c\private\e5c48996\Sound.wav" \
    }

    Even though you will see a "symbian:TARGET.UID3 = ~~~ ", just paste below it, it's ok.
    You don't have to adjust the sound object creation code, just leave it.
    [this is assuming this is your sound creation code:
    QSound* bs = new QSound("Sound.wav");
    bs->play();
    ]


    For the Actual Phone Deployment to work, in the *.pkg file [not the _template.pkg file], enter this:
    "Sound.wav" -"!:\private\E5C48996\Sound.wav"


    This is made possible thanks to help from fellow forum member:
    WolfgangDamm and treinio for providing the information directly

  13. #13
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: How to QSound ?

    Quote Originally Posted by Jack Torrance View Post
    Another, easier way is to have it in Qt resources, then you refer to it as
    QSound :: play (":/prefix/finame.wav")

    See http://doc.trolltech.com/4.6/resources.html

    Jack
    Hi,.
    sorry to warm up such an old thread!

    I have just checked the doc, and it says that QSound does NOT allow the usage of resources!
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  14. #14
    Registered User
    Join Date
    Feb 2009
    Posts
    8

    Re: How to QSound ?

    Quote Originally Posted by tamhanna View Post
    Hi,.
    sorry to warm up such an old thread!

    I have just checked the doc, and it says that QSound does NOT allow the usage of resources!
    There is a simple workaround for this problem: You can use QFile::copy API to store the sound from the resource to a local file on disk first, then play from the file using QSound. However, there are also other problems using QSound on Symbian... You can read about my adventures using QSound in here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •