Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Play sound using qml in resource on Symbian
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Play sound using qml in resource on Symbian

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlterX
    wrote on last edited by
    #1

    I'm getting crazy with that!!!
    I've tried to use SoundEffect or Audio qml tag within qml located in resource (also the audio file was in a resource file).
    I've tried in C++ using a real audio file (copying it with DEPLOYMENTFOLDERS) and QMediaPlayer: the file path was correct but I have not heard anything!
    I'm in process of create an app fpr both symbian and meego, so I want to use the same code (on MeeGo, using qml and sound files in the resource works just with SoundEffect tag; the same doesn't work on symbian).
    How can I achieve that??
    I've tested it on a nokia x7 and c7

    Thank you

    Qt Ambassador
    Real-time cooperative teams: http://www.softairrealfight.net
    Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

    https://codereview.qt-project.org/...

    1 Reply Last reply
    0
    • F Offline
      F Offline
      feldifux
      wrote on last edited by
      #2

      Hi,
      I am also using the QML SoundEffect and Audio element from QtMultimediaKit 1.1 for both Symbian and Meego for a game. From my experience, they both work with the same code. However, Meego has some troubles with multiple simultaneous sound effects while a background music (Audio) is playing.

      Maybe your issues have something to do with the audio sampling rate or frequency? The background music I'm using for the Audio element has a frequency of 48kHz and 128kbit quantization, the file format is mp3. An example for a working sound effect is a wav file with 44.1kHz, 1 channel and 16 bits per sample.

      These audio files are loaded with the DEPLOYMENTFOLDERS approach, so not from the resource file.

      I hope that helps?

      Founder of Felgo SDK - http://felgo.com/qt

      Felgo simplifies

      • Mobile App Dev with Qt esp. iOS & Android
      • Game Development with Qt

      What others say

      Felgo scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlterX
        wrote on last edited by
        #3

        Hi, thank you for your help...
        I have some experience on symbian and meego handling sounds; I've done a game using sounds as you said, but in the case of qml within resource, that works only on meego! i don't know why.
        If the qml isn't in resource file, the DEPLOYEMNTFOLDERS works very well!
        As I told, i've tried to copy sounds in to device and open that (always in qml within resource) without success!
        Why the same tecnique doesn't work for both?!

        Qt Ambassador
        Real-time cooperative teams: http://www.softairrealfight.net
        Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

        https://codereview.qt-project.org/...

        1 Reply Last reply
        0
        • F Offline
          F Offline
          feldifux
          wrote on last edited by
          #4

          I'm afraid I dont know why playing from resources isnt working on Symbian.. Is just using the deploymentfolders approach not an option for you?

          So as a recap:

          • sounds & qml as deploymentfolders -> works on Symbian & meego
          • qml in resource, sound not in resource but with deploymentfolders -> does NOT work on symbian, but works on meego
          • what about both, the qml file and sound file in resource?

          cheers,
          Chris

          Founder of Felgo SDK - http://felgo.com/qt

          Felgo simplifies

          • Mobile App Dev with Qt esp. iOS & Android
          • Game Development with Qt

          What others say

          Felgo scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AlterX
            wrote on last edited by
            #5

            It's very difficult to recap;
            In my experience, on Symbian I've always used qml and sounds as normal files and not in resources; on the other side, on Meego I've always used qml and sounds as resources;
            i'm not crazy if I did that...I suppose that on meego works both method!
            1- Sounds & qml as deploymentfolders: valid for Symbian & Meego
            2- Qml in resources and sounds on deploymentfolders doesn't work for both (on Symbian sure!)
            3- Actually, qmls & sounds in resources work only for Meego

            I think that is because when you use qml/js in resource and use relative path for sounds, it translate absolute path as "qrc:/bla/bla.wav"

            Qt Ambassador
            Real-time cooperative teams: http://www.softairrealfight.net
            Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

            https://codereview.qt-project.org/...

            1 Reply Last reply
            0
            • F Offline
              F Offline
              feldifux
              wrote on last edited by
              #6

              Yes you are right, based on the setMainQmlFile() call (in case you are using the QmlApplicationViewer), the baseUrl of the QDeclarativeEngine is set. So if you call setMainQmlFile(":/main.qml"), every qml file, image or sound file is prepended with ":/".

              So the easiest approach to me seems, to just use deploymentfolders on both platforms. If that is not an option, you could use qml & sounds in the resources for Meego, and from deploymentfolders for Symbian. So you could decide at runtime which one to use like this:
              @
              #if defined(Q_OS_SYMBIAN)
              // on symbian use the copied files with DEPLOYMENTFOLDERS
              qmlApplicationViewer->setMainQmlFile("main.qml");
              #elif defined(MEEGO_EDITION_HARMATTAN)
              // on meego use the resources
              qmlApplicationViewer->setMainQmlFile(":/main.qml");
              #else
              // for desktop, whatever you prefer
              qmlApplicationViewer->setMainQmlFile("main.qml");
              @

              Founder of Felgo SDK - http://felgo.com/qt

              Felgo simplifies

              • Mobile App Dev with Qt esp. iOS & Android
              • Game Development with Qt

              What others say

              Felgo scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AlterX
                wrote on last edited by
                #7

                Sure...nice, maybe it could be a good idea!!

                Qt Ambassador
                Real-time cooperative teams: http://www.softairrealfight.net
                Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                https://codereview.qt-project.org/...

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AlterX
                  wrote on last edited by
                  #8

                  [quote author="feldifux" date="1342621086"]
                  So you could decide at runtime which one to use
                  [/quote]

                  I've used this way and even is a huge solution (resources and files) it works very well on both!!

                  Qt Ambassador
                  Real-time cooperative teams: http://www.softairrealfight.net
                  Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                  https://codereview.qt-project.org/...

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved