Play Audio Files using Qt Mobility
hamishwillee
(Talk | contribs) m (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan") |
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot update - Add ArticleMetaData) |
||
| Line 1: | Line 1: | ||
| + | {{ArticleMetaData <!-- v1.2 --> | ||
| + | |sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | ||
| + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| + | |devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') --> | ||
| + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) --> | ||
| + | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
| + | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | ||
| + | |signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20100331 | ||
| + | |author= [[User:Skumar rao]] | ||
| + | }} | ||
[[Category:Qt Mobility]] | [[Category:Qt Mobility]] | ||
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | ||
| Line 19: | Line 41: | ||
|} | |} | ||
| − | {{Tip| Read this article before moving forward: [[Setting up environment for Qt Mobility API]]}} | + | {{Tip| Read this article before moving forward: [[Archived:Setting up environment for Qt Mobility API]]}} |
== Overview == | == Overview == | ||
Revision as of 08:58, 25 July 2012
Article Metadata
| 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: Read this article before moving forward: Archived:Setting up environment for Qt Mobility API
Contents |
Overview
This article shows how to 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
#include <qurl.h>
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
- Qt - cross-platform application and UI framework
- Qt Mobility API
- New Qt APIs Beta - Mobility Project
- SDK help
--skumar_rao 16:50, 31 March 2010 (UTC)

