×
Namespaces

Variants
Actions

Using MPX Playback Utility Symbian API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Tested on: Nokia N97,
Nokia N97 Mini, Nokia X6
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Article
Keywords: MMPXPlaybackUtility
Created: User:Kbwiki (23 Nov 2010)
Last edited: hamishwillee (01 Aug 2012)

Description

MPX architecture provides clear and simple high level interfaces for multiple clients to manage collections, audio playback, and user interfaces. MMPXPlaybackUtility is an interface for the playback of audio content. Through this utility, clients can start the playback of media, retrieve the current playback state, retrieve playback properties such as volume and position, and send commands to control playback such as pause, stop, seek forward, backward, or skip to next track. Clients can retrieve other interfaces including MMPXPlayer and MMPXSource from the MMPXPlaybackUtility API. On the other hand, the class MMPXPlaybackObserver provides message and event call back respectively. The code below shows how to start the playback of a song.

Prerequisite

The MPX APIs plug-in pack must be installed. It is available at: http://www.developer.nokia.com/Resources/Tools_and_downloads/Other/S60_extensions_plugins/Features.xhtml

Solution

  // MPXPlayback.h 
#include <mpxplaybackutility.h>
#include <mpxplaybackobserver.h>
#include <mpxmessagegeneraldefs.h>
#include <mpxplaybackmessage.h>
 
_LIT(KSong,"C:\\Data\\My_Song.mp3");
 
// Class declaration
class CMPXPlayback : public CBase, public MMPXPlaybackObserver
{
public:
// Creates and Initializes the utility class with a song
void InitalizeL();
private:
// From MMPXPlaybackObserver
void HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError );
private:
MMPXPlaybackUtility* iPlaybackUtility;
};
 
//MPXPlayback.cpp
// Constructor
CMPXPlayback::CMPXPlayback()
{
iPlaybackUtility = NULL;
}
// Destructor
CMPXPlayback::~CMPXPlayback()
{
if (iPlaybackUtility)
{
TRAP_IGNORE( iPlaybackUtility->CommandL( EPbCmdClose ) );
iPlaybackUtility->Close();
delete iPlaybackUtility;
iPlaybackUtility = NULL;
}
}
 
void CMPXPlayback::InitalizeL()
{
iPlaybackUtility = MMPXPlaybackUtility::NewL(KPbModeDefault);
// Add observer
iPlaybackUtility->AddObserverL(*this );
// Inititialises with a single item
iPlaybackUtility->InitL(KSong);
}
 
//callback from MMPXPlaybackObserver, Handling Playback messages
void CMPXPlayback::HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError )
{
TMPXMessageId id(*aMessage->Value<TMPXMessageId>(KMPXMessageGeneralId));
if(id==KMPXMessageGeneral)
{
// Get the current event
TInt event(*aMessage->Value<TInt> (KMPXMessageGeneralEvent));
TInt type(*aMessage->Value<TInt> (KMPXMessageGeneralType));
TInt data(*aMessage->Value<TInt> (KMPXMessageGeneralData));
if(event==TMPXPlaybackMessage::EInitializeComplete)
{
// send the Play/Pause toggle command
TRAPD(err,iPlaybackUtility->CommandL(EPbCmdPlayPause));
}
}
}

A sample application can be downloaded from: Media:MPXPlayBackUtilit.zip

This page was last modified on 1 August 2012, at 07:41.
77 page views in the last 30 days.
×