Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Play Audio Files using Qt Mobility

From Wiki
Jump to: navigation, search
somnathbanik (Talk | contribs)
somnathbanik (Talk | contribs)
Line 22: Line 22:
== Overview ==  
== Overview ==  
{{Abstract| This article shows how to Play Audio Files(supported) using [[Qt Mobility]].}}
{{Abstract| This article shows how to Play Audio Files(supported) using Qt Mobility.}}
== Keywords ==
== Keywords ==

Revision as of 14:24, 19 May 2011

ID Creation date 31st Mar 2010
Platform S60 5th Edition Tested on devices Nokia N97 Mini
Category Qt Subcategory Qt Mobility API

Keywords (APIs, classes, methods, functions): QMediaPlayer, QMediaPlaylist

Tip.pngTip: Read this article before moving forward: Setting up environment for Qt Mobility API



This article shows how to Play Audio Files(supported) using Qt Mobility.


Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += multimedia

Header File

#include <qmediaplayer.h>
#include <qmediaplaylist.h>
private slots:
void statusChanged(QMediaPlayer::MediaStatus status);
QMediaPlayer *player;
QMediaPlaylist *playlist;

Source File

#include <qurl.h>
player = new QMediaPlayer(this);
player->setVolume(50); // set Volume
playlist = new QMediaPlaylist(this);
connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
playlist->addMedia(QUrl::fromLocalFile("c:\\data\sample.mp3")); // you can add as many media files as you want

void QtPlayerAudio::statusChanged(QMediaPlayer::MediaStatus status) {
switch (status) {
case QMediaPlayer::LoadedMedia:


  • QMediaPlayer
  • QMediaPlaylist

Reference links

--skumar_rao 16:50, 31 March 2010 (UTC)

84 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.