|
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 * Launch MPX player. |
|
129 */ |
|
130 void LaunchMusicPlayerL(); |
|
131 |
|
132 private: |
|
133 enum TOpState |
|
134 { |
|
135 EIdle = 0, |
|
136 ERespondPlayOk , // responding OK to play command is outstanding |
|
137 ERespondPlayNok, // responding NOT OK to play command is outstanding |
|
138 EPlayMusicTiming, // scheduling internal PLAY command to player |
|
139 }; |
|
140 |
|
141 private: // Data |
|
142 |
|
143 CRemConCoreApiTarget* iCoreTarget; // not own |
|
144 |
|
145 RTimer iTimer; |
|
146 |
|
147 TOpState iState; |
|
148 }; |
|
149 |
|
150 #endif // BTRCCACLLINKLISTENER_H |
|
151 |
|
152 // End of File |