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. Need to stop QML Audio from cpp code
Forum Updated to NodeBB v4.3 + New Features

Need to stop QML Audio from cpp code

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.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.
  • S Offline
    S Offline
    srav219
    wrote on last edited by
    #1

    Hi,
    I have a qml which has audio playing.I need to pause the audio from QAPPlication ie cpp code.
    *
    QML CODE is as follows


    import Qt 4.7
    import QtMultimediaKit 1.1

    Text {
    text: "Click Me!";
    font.pointSize: 24;
    width: 150; height: 50;

     Audio {
         id: playMusic
         source: "music.wav"
     }
     MouseArea {
         id: playArea
         anchors.fill: parent
         onPressed:  { playMusic.play() }
     }
    

    }


    When i hide my qml app ,I need to pause the audio playing.
    This is straight forward pausing in qml file by using signals and slots
    I need to pause the audio from cpp code .

    Please post me

    1 Reply Last reply
    0
    • S Offline
      S Offline
      srav219
      wrote on last edited by
      #2

      One more thing ,I should know the Media that is playing and I should pause the media like in cpp code

      if(any media Object playing)
      // pause the media

      Again one my qml comes to foreground and if press play ,Audio should resume from where it has stopped

      1 Reply Last reply
      0
      • martin_kyM Offline
        martin_kyM Offline
        martin_ky
        wrote on last edited by
        #3

        Take a look at the documentation: "Using QML Bindings in C++ Applications.":http://qt-project.org/doc/qt-4.8/qtbinding.html In particular, the section Exchanging Data between QML and C++ may be of interest to you.

        However, it is discouraged to modify a QML scene directly from C++, because it creates an unnecessary tight coupling between the UI and code-behind. Better way is to expose a QObject "model" to QML. Your QML scene state can then be controlled using the your model object's Q_PROPERTIEs. See the section Embedding C++ Objects into QML Components in the same doc article on how to expose objects from C++ to QML.

        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