bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h
branchRCL_3
changeset 61 269724087bed
parent 56 9386f31cc85b
child 64 1934667b0e2b
equal deleted inserted replaced
56:9386f31cc85b 61:269724087bed
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This class implements starting Music play	
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef BTRCCPLAYERSTATER_H
       
    21 #define BTRCCPLAYERSTATER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <remconcoreapitargetobserver.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CRemConCoreApiTarget;
       
    29 
       
    30 /**
       
    31 *  This class listens to AVRCP PLAY command by headset,if music player is not running 
       
    32 *  when such a command is received, it will be launched and requested to start playing.
       
    33 * */
       
    34 NONSHARABLE_CLASS(CPlayerStarter) : 
       
    35     public CActive, public MRemConCoreApiTargetObserver
       
    36 	{
       
    37 	
       
    38 public:
       
    39 
       
    40 	/**
       
    41 	* Two-phased constructor.
       
    42 	*      
       
    43 	*/
       
    44 	static CPlayerStarter* NewL();
       
    45 
       
    46 	/**
       
    47 	 * Set the reference for AVRCP Core API command receiving and
       
    48 	 * responses to those command.
       
    49 	 */
       
    50 	void SetCoreTarget(CRemConCoreApiTarget& aTarget);
       
    51 	
       
    52 	/**
       
    53 	* Destructor.
       
    54 	*/
       
    55 	~CPlayerStarter();
       
    56 	
       
    57 private:  // From CActive
       
    58 
       
    59     /**
       
    60     * Informs the observer that an accessory has created a control 
       
    61     * connection to our device.
       
    62     * @param                            None.
       
    63     * @return                           None.
       
    64     */
       
    65     void RunL();
       
    66 
       
    67     /**
       
    68     * Handles a possible leave from RunL().
       
    69     * @param aError                     The leave code from RunL().
       
    70     * @return                           KErrNone.
       
    71     */
       
    72     TInt RunError(TInt aError);
       
    73 
       
    74     /**
       
    75     * Cancels the volume change operation.
       
    76     * @param                            None.
       
    77     * @return                           None.
       
    78     */
       
    79     void DoCancel();
       
    80     
       
    81     // from base class MRemConCoreApiTargetObserver
       
    82 
       
    83     /**
       
    84      * From MRemConCoreApiTargetObserver
       
    85      * A 'play' command has been received.
       
    86      *
       
    87      * @param aSpeed The playback speed.
       
    88      * @param aButtonAct The button action associated with the command.
       
    89      */
       
    90     void MrccatoPlay(
       
    91         TRemConCoreApiPlaybackSpeed aSpeed,
       
    92         TRemConCoreApiButtonAction aButtonAct );
       
    93 
       
    94     /**
       
    95      * From MRemConCoreApiTargetObserver
       
    96      * A command has been received.
       
    97      *
       
    98      * @param aOperationId The operation ID of the command.
       
    99      * @param aButtonAct The button action associated with the command.
       
   100      */
       
   101     void MrccatoCommand(
       
   102         TRemConCoreApiOperationId aOperationId,
       
   103         TRemConCoreApiButtonAction aButtonAct );
       
   104 
       
   105 private:
       
   106 
       
   107         /**
       
   108         * C++ default constructor.
       
   109         */
       
   110         CPlayerStarter();
       
   111 
       
   112         /**
       
   113         * Symbian 2nd phase constructor.
       
   114         */
       
   115         void ConstructL();
       
   116 
       
   117         /**
       
   118          * Start music player if it is not running yet.
       
   119          */
       
   120         void StartPlayIfNeeded();
       
   121         
       
   122         /**
       
   123          * Tells if MPX music player is running or not.
       
   124          */
       
   125         TBool IsMusicPlayerRunning();
       
   126         
       
   127         /**
       
   128          * Tells if Video player is running or not.
       
   129          */
       
   130         TBool IsVideoPlayerRunning();
       
   131 
       
   132         /**
       
   133          * Launch MPX player.
       
   134          */
       
   135         void LaunchMusicPlayerL();
       
   136         
       
   137 private:
       
   138     enum TOpState
       
   139         {
       
   140         EIdle = 0, 
       
   141         ERespondPlayOk , // responding OK to play command is outstanding
       
   142         ERespondPlayNok,   // responding NOT OK to play command is outstanding
       
   143         EPlayMusicTiming,  // scheduling internal PLAY command to player
       
   144         };
       
   145     
       
   146 private:    // Data
       
   147     
       
   148     CRemConCoreApiTarget* iCoreTarget; // not own
       
   149     
       
   150 	RTimer iTimer;
       
   151 	
       
   152 	TOpState iState;
       
   153     };
       
   154 
       
   155 #endif      // BTRCCACLLINKLISTENER_H
       
   156             
       
   157 // End of File