Need to stop QML Audio from cpp code
-
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.1Text {
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
-
-
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.