Play Audio Files using Qt Mobility
somnathbanik
(Talk | contribs) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (5 intermediate revisions by 2 users not shown) | |||
| 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 == | ||
| − | {{Abstract| This article shows how to Play Audio Files(supported) using | + | {{Abstract| This article shows how to Play Audio Files(supported) using Qt Mobility.}} |
== Keywords == | == Keywords == | ||
| Line 28: | Line 50: | ||
== Project configuration file (.Pro file) == | == Project configuration file (.Pro file) == | ||
* Add the Qt Mobility project configuration option in the '''.Pro''' file as shown below | * Add the Qt Mobility project configuration option in the '''.Pro''' file as shown below | ||
| − | <code cpp> | + | <code cpp-qt> |
CONFIG += mobility | CONFIG += mobility | ||
MOBILITY += multimedia | MOBILITY += multimedia | ||
| Line 34: | Line 56: | ||
== Header File == | == Header File == | ||
| − | <code cpp> | + | <code cpp-qt> |
#include <qmediaplayer.h> | #include <qmediaplayer.h> | ||
#include <qmediaplaylist.h> | #include <qmediaplaylist.h> | ||
| Line 47: | Line 69: | ||
== Source File == | == Source File == | ||
| − | <code cpp> | + | <code cpp-qt> |
#include <qurl.h> | #include <qurl.h> | ||
| Line 65: | Line 87: | ||
| − | <code cpp> | + | <code cpp-qt> |
void QtPlayerAudio::statusChanged(QMediaPlayer::MediaStatus status) { | void QtPlayerAudio::statusChanged(QMediaPlayer::MediaStatus status) { | ||
switch (status) { | switch (status) { | ||
| Line 84: | Line 106: | ||
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework] | * [http://qt.nokia.com/ Qt - cross-platform application and UI framework] | ||
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API] | * [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API] | ||
| − | * [http://qt.nokia.com/developer/ | + | * [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project] |
* SDK help | * SDK help | ||
| − | --[[User:Skumar rao|Skumar rao]] 16:50, 31 March 2010 (UTC) | + | --[[User:Skumar rao|Skumar rao]] 16:50, 31 March 2010 (UTC)[[Category:MeeGo Harmattan]] [[Category:Symbian]] |
Latest revision as of 04:23, 11 October 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)

