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. Sound
Forum Updated to NodeBB v4.3 + New Features

Sound

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 3.4k 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.
  • M Offline
    M Offline
    mikealfa
    wrote on last edited by
    #1

    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
    0
    • V Offline
      V Offline
      Vicky
      wrote on last edited by
      #2

      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
      0
      • D Offline
        D Offline
        dajansen
        wrote on last edited by
        #3

        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
        0
        • M Offline
          M Offline
          mikealfa
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dajansen
            wrote on last edited by
            #5

            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
            0
            • M Offline
              M Offline
              mikealfa
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bread19
                wrote on last edited by
                #7

                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
                0

                • Login

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