Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Sound

    QML and Qt Quick
    4
    7
    2892
    Loading More Posts
    • 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.
    • M
      mikealfa last edited by

      I want a piece of music to be played as my application begins and till its closed.....how can i do that ??

      1 Reply Last reply Reply Quote 0
      • V
        Vicky last edited by

        i know how to do it in qml.....not in qt c++...

        here goes...

        use a Timer....where onTrigger of that state(in Qml) the music starts playing...and when closing the app...u dont have to stop the music there because when u kill the application...everything shuts down.

        1.) use an import called
        import QtMultimediaKit 1.1

        2.) then.....
        add the sound file to your project folder ie. in the qml folder(urproject/qml/sounds/)....
        then use that in your application...
        by using this code....

        @Audio{
        id:menusound
        source:"sounds/electropoly.mp3"
        }@

        3.) then use a timer to make that file work in your app...
        @Timer{
        id:soundtimer
        interval:1;
        repeat:true;
        running:false;
        onTriggered: menusound.play();
        }@

        4.) then use another timer or....an on clicked function(if u require) to call the file to play....
        @Timer {
        id:start;
        interval: 1000;
        running: false;
        onTriggered: {
        rect.state = "menu"; /* play the file after it comes to this state!! */
        soundtimer.running = true;
        }
        }@

        dont forget to give ids to the timers u create or any object/item that you create....because it will be easier for you to use them else where in your code.

        Vikram

        1 Reply Last reply Reply Quote 0
        • D
          dajansen last edited by

          I disagree that using a Timer is a good solution to replaying a sound file. You may have a delay of up to a full second.

          Just use:
          @ Audio { source: "mymusic.mp3"; playing: true; onStopped: play(); }@

          QtQuick Quality Engineer / Lab Monkey
          Nokia Brisbane

          1 Reply Last reply Reply Quote 0
          • M
            mikealfa last edited by

            i tried both guyz...
            but it says "QtMultimediakit" not installed...
            how to fix this now

            1 Reply Last reply Reply Quote 0
            • D
              dajansen last edited by

              Firstly, ensure you have specified
              @import QtMultimediaKit 1.1@

              That is, capital Q, capital M, capital K.

              Second, for some platforms, in your .pro I believe you require:
              @CONFIG+=mobility
              MOBILITY+=multimedia@

              QtQuick Quality Engineer / Lab Monkey
              Nokia Brisbane

              1 Reply Last reply Reply Quote 0
              • M
                mikealfa last edited by

                yep...i treid that too...bt still says "QtMultimediaKit" not installed :(

                1 Reply Last reply Reply Quote 0
                • B
                  bread19 last edited by

                  You should install QtMobility manually. I tried a couple of times for QtMobility. It does not automatically get installed by SDK. Compile QtMobility and install into the Qt base directory.
                  This will solve your problem.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post