Categories: Symbian C++ | FNWiki | S60 | Multimedia | Audio | Code Examples
This page was last modified 05:26, 2 July 2008.
Music Player Remote Control API
From Forum Nokia Wiki
| Note! |
|---|
|
The main purpose of Music Player Remote Control is to implement remote controlling functionality. It also provides playback information for remote clients.
Header Files:
#include <MPlayerRemoteControl.h> #include <MPlayerConstants.h>
Link against:
LIBRARY mplayerremotecontrol.lib
CAPABILITY:
CAPABILITY ReadDeviceData ReadUserData WriteUserData WriteDeviceData
Use cases
-Get the Title, Artist of the currently playing track
-Get/Set the volume of music player.
-Get the duration, current position of the playing track.
-Get/Set the playback mode, ie, shuffle and repeat mode.
-Get the List of categories, tracks etc.
Example code
1)Derive your class from MMPlayerPlaybackObserver & MMPlayerDbObserver and implement the functions in them.
2)Create an Object of MMPlayerRemoteControl and register it as an observer so that you can get the callbacks.
iEngine = MPlayerRemoteControlFactory::NewRemoteControlL(); iEngine->RegisterObserver(this); iEngine->SetDbObserverL(this)
-Get the current track's title info:
TBuf<128> iBuf; iBuf.Copy(iEngine->Title()); CEikonEnv::InfoWinL(_L("Track Playing :"),iBuf);
-Get the current track's artist info
iBuf.Copy(iEngine->Artist()); CEikonEnv::InfoWinL(_L("Artist :"),iBuf);
-Get the Music Player playback position
iBuf.AppendNum(iEngine->Position()); CEikonEnv::InfoWinL(_L("Current Position :"),iBuf);
-Get the current track's duration
iBuf.AppendNum(iEngine->Duration()); CEikonEnv::InfoWinL(_L("Track Duration :"),iBuf);
-Get current track's playlist details
TInt lCurrentIndex; TInt lCount; iEngine->GetPlaylistInfo(lCurrentIndex,lCount); iBuf.Zero(); iBuf.AppendNum(lCurrentIndex); CEikonEnv::InfoWinL(_L("Current Index in Playlist :"),iBuf); iBuf.Zero(); iBuf.AppendNum(lCount); CEikonEnv::InfoWinL(_L("Count in Playlist :"),iBuf);
-Get the players Current State
MPlayerRemoteControlState lState = iEngine->PlayerState(); switch (lState) { case EMPlayerRCtrlNotRunning: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Not Running")); } break; case EMPlayerRCtrlNotInitialised: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Not Initialised")); } break; case EMPlayerRCtrlInitialising: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Initialising")); } break; case EMPlayerRCtrlStopped: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Stopped")); } break; case EMPlayerRCtrlPlaying: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Playing")); } break; case EMPlayerRCtrlPaused: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Paused")); } break; case EMPlayerRCtrlSeekingForward: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Seeking Forward")); } break; case EMPlayerRCtrlSeekingBackward: { CEikonEnv::InfoWinL(_L("Player State : "),_L("Seeking Backward")); } break; default : break; }
-Get\Set the Volume
iBuf.AppendNum(iEngine->MaxVolume()); CEikonEnv::InfoWinL(_L("MaxVolume :"),iBuf); iBuf.AppendNum(iEngine->Volume()); CEikonEnv::InfoWinL(_L("Volume :"),iBuf); iEngine->SetVolume(2);
-Get the playback mode
TBool iBool; TMPlayerRepeatMode iMode; TInt err = iMusicRemConEngine->GetPlaybackMode(iBool,iMode); if(!err) { if (iBool) { CEikonEnv::InfoWinL(_L("Shuffle On"),_L("")); } else { CEikonEnv::InfoWinL(_L("Shuffle Off"),_L("")); } switch(iMode) { case EMPlayerRepeatOff: { CEikonEnv::InfoWinL(_L("Repeat Off"),_L("")); } break; case EMPlayerRepeatOne: { CEikonEnv::InfoWinL(_L("Play one track over and over again"),_L("")); } break; case EMPlayerRepeatAll: { CEikonEnv::InfoWinL(_L("Repeat All"),_L("")); } break; default: break; } }
-Set the Playback mode
iEngine->SetPlaybackMode(ETrue,EMPlayerRepeatOff);// Shuffle On & Repeat Off
Example project
Known Issues
KIS001005 Music Player Remote Control API does not work in all S60 3rd Edition FP1 and FP2 devices
Related Links
TSS000877 - Launching the Nseries Music Player in a certain view
KIS000800 - S60 music player cannot be launched in standalone mode
