I've installed the Ubuntu QML Toolkit Preview as per the instructions on http://developer.ubuntu.com/get-started/gomobile/ (with a minor fiddle to get it working on 12.04). I'm trying to write an app that plays a sound file. Aparrently you can do this using QtMultiMediakit in QtQuick 1, but not in QtQuick 2 as used by the toolkit.

Is it possible to write an app using the toolkit that plays sound?

  • Just of interest, which instructions did you follow to install Ubuntu on Nexus 7?
    – mlvljr
    Jan 7, 2013 at 11:50
  • 1
    I'm not sure which part of my post suggests I'm running Ubuntu on a Nexus 7, but I'm not. Jan 8, 2013 at 14:11
  • okay, I am looking up to doing that myself, and obviously was too anxious :) But isn't Ubuntu QML toolkit targeted at phones/tablets?
    – mlvljr
    Jan 8, 2013 at 21:16

2 Answers 2


Problem solved, the answer is to use QtMultimedia 5.0, which now provides the Audio element.


  • In my case, I seemed to need libqt5multimedia5-plugins installed and the SDK didn't pull this in by default. Jul 30, 2013 at 19:45

Here's a quick example of how to play an mp3 file using MediaPlayer component from QtMultimedia and the Ubuntu UI toolkit:

import QtQuick 2.0
import Ubuntu.Components 0.1
import QtMultimedia 5.0

MainView {
    width: units.gu(100)
    height: units.gu(75)

    Page {
        title: i18n.tr("Simple Player")

        MediaPlayer {
            id: player
            source: "foo.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){
                    pressed = false
                    text = i18n.tr("Play")
                    pressed = true
                    text = i18n.tr("Stop")

It looks like so:

example player app


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .