×
Namespaces

Variants
Actions
Revision as of 19:50, 31 March 2010 by skumar_rao (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Play Audio Files using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
ID Creation date 31st Mar 2010
Platform S60 5th Edition Tested on devices Nokia N97 Mini
Category Qt for Symbian 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

Contents

Overview

Play Audio Files(supported) using Qt Mobility.

Keywords

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);
private:
QMediaPlayer *player;
QMediaPlaylist *playlist;

Source File

player = new QMediaPlayer(this);
player->setVolume(50); // set Volume
playlist = new QMediaPlaylist(this);
playlist->setMediaObject(player);
 
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
 
player->play();
void QtPlayerAudio::statusChanged(QMediaPlayer::MediaStatus status) {
switch (status) {
case QMediaPlayer::LoadedMedia:
player->play();
break;
default:
break;
}
}

Classes

  • QMediaPlayer
  • QMediaPlaylist

Reference links

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

124 page views in the last 30 days.
×