Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've installed the Ubuntu QML Toolkit Preview as per the instructions on (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?

share|improve this question
Just of interest, which instructions did you follow to install Ubuntu on Nexus 7? – mlvljr Jan 7 '13 at 11:50
I'm not sure which part of my post suggests I'm running Ubuntu on a Nexus 7, but I'm not. – marxjohnson Jan 8 '13 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 '13 at 21:16
up vote 8 down vote accepted

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

share|improve this answer
In my case, I seemed to need libqt5multimedia5-plugins installed and the SDK didn't pull this in by default. – andrewsomething Jul 30 '13 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 {

    Page {
        title:"Simple Player")

        MediaPlayer {
            id: player
            source: "foo.mp3"
            onStatusChanged: {
                if (status == MediaPlayer.EndOfMedia) {
                    button.pressed = false
                    button.text ="Play")

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

It looks like so:

example player app

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.