×
Namespaces

Variants
Actions
(Difference between revisions)

Play Audio Files using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
Line 50: 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 56: Line 56:
  
 
== Header File ==
 
== Header File ==
<code cpp>
+
<code cpp-qt>
 
#include <qmediaplayer.h>
 
#include <qmediaplayer.h>
 
#include <qmediaplaylist.h>
 
#include <qmediaplaylist.h>
Line 69: Line 69:
 
== Source File ==
 
== Source File ==
  
<code cpp>
+
<code cpp-qt>
 
#include <qurl.h>
 
#include <qurl.h>
  
Line 87: Line 87:
  
  
<code cpp>
+
<code cpp-qt>
 
void QtPlayerAudio::statusChanged(QMediaPlayer::MediaStatus status) {
 
void QtPlayerAudio::statusChanged(QMediaPlayer::MediaStatus status) {
 
     switch (status) {
 
     switch (status) {

Latest revision as of 04:23, 11 October 2012

Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: skumar_rao (31 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)
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: Archived:Setting up environment for Qt Mobility API

Contents

[edit] Overview

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

[edit] Keywords

[edit] Project configuration file (.Pro file)

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

[edit] Header File

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

[edit] 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;
}
}

[edit] Classes

  • QMediaPlayer
  • QMediaPlaylist

[edit] Reference links

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

This page was last modified on 11 October 2012, at 04:23.
145 page views in the last 30 days.