Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Music Player Remote Control API

From Wiki
Jump to: navigation, search
Article Metadata
Code ExamplePlatform Security
Signing Required: DevCert or Symbian Signed
Capabilities: ReadDeviceData ReadUserData WriteUserData WriteDeviceData
Article
Created: ltomuta (17 Jun 2007)
Last edited: hamishwillee (14 Jun 2013)

Note.pngNote: This API is not part of the public SDK. It can be found in the SDK API Plug-in.

The article shows how to use the Symbian C++ Music Player Remote Control API and provide 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

File:MusicRemConEx.zip



Known Issues

KIS001005 Music Player Remote Control API does not work in all S60 3rd Edition FP1 and FP2 devices

Related Links

This page was last modified on 14 June 2013, at 04:58.
40 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×