×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    3

    Help: How to get "Now Playing" song from Native media player in Symbian C++ ?

    Hi All,

    I am new to the forum. And i wanted to know are there any api's to access the currently played song in the media player. I will need to fetch this data from my Qt app.

    If media player is playing a song in the background, i should be able to get the currently played song in my application. Is this possible ??
    After exploring, i got CMPRecentList class to get the recentlyplayed playlist details. But not the currently played one. Can anyone please help me out in getting this data from music player api's...

    Many thanks in advance.

    Regards,
    Vin

  2. #2
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    53

    Re: Help: How to get "Now Playing" song from Native media player in Symbian C++ ?

    Hi,

    Please check below link. The link talks about call backs regarding the media player
    http://www.developer.nokia.com/Commu...ck_Utility_API

    Best Regards
    Raghava

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    3

    Re: Help: How to get "Now Playing" song from Native media player in Symbian C++ ?

    thanks for the reply Raghava. It helped a lot.

    I have one issue using these. couldnt find a doc where they have mentioned how to use MMPXPlaybackUtility api's. So i tried a way, but its not working for me. . Could anyone help me out ???

    I found api's to get the currently played song in utility api's and my code looks like this:


    In constructL:
    iPlaybackUtility = MMPXPlaybackUtility::NewL(KPbModeActivePlayer);
    iPlaybackUtility->AddObserverL(*this );

    In destructor:
    if (iPlaybackUtility)
    {
    iPlaybackUtility->Close();
    delete iPlaybackUtility;
    iPlaybackUtility = NULL;
    }
    }

    The virtual methods for Observer class and callback classes are implemented as follows:

    void xyz::HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError )
    {
    if ( aMessage && KErrNone == 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::ESongChanged)
    {
    TRAP_IGNORE( GetNewTrackInfoL() );
    }
    }
    }

    void xyz::GetNewTrackInfoL()
    {
    TMPXPlaybackState currentState = iPlaybackUtility->StateL();

    // Do not request trackinfo if MP is closing
    if (( currentState != EPbStateNotInitialised ) && (currentState != EPbStateShuttingDown ))
    {
    // Request title and duration from current media
    RArray<TMPXAttribute> attrs;
    CleanupClosePushL( attrs );
    attrs.AppendL( KMPXMediaGeneralTitle );
    MMPXSource* source = iPlaybackUtility->Source();
    if( source )
    {
    source->MediaL( attrs.Array(), *this );
    }
    CleanupStack::PopAndDestroy( &attrs );
    }
    }


    void xyz::HandlePropertyL(TMPXPlaybackProperty aProperty,
    TInt aValue,
    TInt aError )
    {
    }


    void xyz::HandleMediaL(const CMPXMedia& aProperties, TInt aError)
    {
    TBuf16<256> title( aProperties.ValueText( KMPXMediaGeneralTitle ) );
    QString titleObtained = QString::fromLocal8Bit(reinterpret_cast<const char *>(title.Ptr()),
    title.Length());
    emit q_ptr->currentSongTitle(titleObtained);

    }


    Currently i am checking the state for ESongChanged and i am changing the song in the music player while my app is running in the background. But i am not getting that callback to ESongChanged statement in my HandleCallbackMessage method. and hence i am not getting the signal emitted which is done in HandleMediaL.
    But when i exit the app, i am getting "application closed:myapplication" followed by 3 more crashes. Dont know I might be forgetting to delete something. Please let me know what is that ????

    Anyone who knows about these api's and its usage please help me out in this..... Your help is appreciated.

    Regards,
    Vinay

Similar Threads

  1. Can I set the player to wait for 5 seconds before playing song?
    By vinnahang in forum Mobile Java General
    Replies: 6
    Last Post: 2012-03-26, 15:28
  2. now playing playlist or song of the native media player from my own app
    By busilo2002 in forum Symbian Media (Closed)
    Replies: 8
    Last Post: 2011-01-07, 11:01
  3. Native media player that support RTSP?
    By brummelisa in forum Mobile Java General
    Replies: 0
    Last Post: 2005-09-14, 14:33
  4. Replies: 0
    Last Post: 2005-07-27, 12:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×