PIRATE FIFI
PIRATE FIFI

Reputation: 271

Ubuntu Touch clickable QML PLugins/audio components

Im trying to create a simple radio app on Ubuntu Touch using the development tool "clickable" yet I cant seem to wrap my head around how to install required QML components.

    MediaPlayer {
        id: player
        source: "https://<some url>.mp3"
        onStatusChanged: {
            if (status == MediaPlayer.EndOfMedia) {
                button.pressed = false
                button.text = i18n.tr("Play")
            }
        }
    }

    Button {
        anchors.centerIn: parent
        id: button
        text: i18n.tr("Play")
        pressed: false
        onClicked: {
            if (player.playbackState == 1){
                player.stop()
                pressed = false
                text = i18n.tr("Play")
            }
            else{
                pressed = true
                text = i18n.tr("Stop")
                player.play()
           }
        }
    }


}

The above code results in the following error

..../Main.qml:39 MediaPlayer is not a type

I've tried installing QTmultimedia using apt-get, with no result. How am I suppose to locally add this component to the project? The project seems to have is own version of QML locally

Upvotes: 0

Views: 120

Answers (1)

iam_peter
iam_peter

Reputation: 3924

Depending on your Qt version and your build system (CMake or qmake) you need to link against the corresponding C++ libraries

qmake

QT += multimedia

CMake

find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(my_project PRIVATE Qt6::Multimedia)

Upvotes: 0

Related Questions