|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "cmtpplaybackresumehelper.h" |
|
22 #include "cmtpplaybackcommand.h" |
|
23 #include "cmtpplaybackcontrolimpl.h" |
|
24 |
|
25 // Constants |
|
26 __FLOG_STMT(_LIT8(KComponent,"PlaybackResumeHelper");) |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CMTPPlaybackResumeHelper::NewL |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CMTPPlaybackResumeHelper* CMTPPlaybackResumeHelper::NewL( |
|
35 CMTPPlaybackControlImpl& aControlImpl ) |
|
36 { |
|
37 CMTPPlaybackResumeHelper* self = new ( ELeave ) |
|
38 CMTPPlaybackResumeHelper( aControlImpl ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CMTPPlaybackResumeHelper::~CMTPPlaybackResumeHelper |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CMTPPlaybackResumeHelper::~CMTPPlaybackResumeHelper() |
|
47 { |
|
48 __FLOG(_L8("+CMTPPlaybackResumeHelper::~CMTPPlaybackResumeHelper")); |
|
49 __FLOG(_L8("-CMTPPlaybackResumeHelper::~CMTPPlaybackResumeHelper")); |
|
50 __FLOG_CLOSE; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CMTPPlaybackResumeHelper::UpdatePrepareCmdArrayL |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CMTPPlaybackResumeHelper::UpdatePrepareCmdArray( TMTPPlaybackCommand aMTPPPBCmd, |
|
58 RResumeCmdArray& aMTPPBMPXCmd ) |
|
59 { |
|
60 __FLOG(_L8("+CMTPPlaybackResumeHelper::UpdatePrepareCmdArrayL")); |
|
61 |
|
62 aMTPPBMPXCmd.Reset(); |
|
63 iIfParepareArray = ETrue; |
|
64 |
|
65 switch ( aMTPPPBCmd ) |
|
66 { |
|
67 case EPlaybackCmdSetPosition: |
|
68 { |
|
69 HandlePlaybackCmdSetPosition( aMTPPBMPXCmd ); |
|
70 } |
|
71 break; |
|
72 default: |
|
73 break; |
|
74 } |
|
75 |
|
76 __FLOG(_L8("-CMTPPlaybackResumeHelper::UpdatePrepareCmdArrayL")); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CMTPPlaybackResumeHelper::UpdateResumeCmdArrayL |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CMTPPlaybackResumeHelper::UpdateResumeCmdArray( TMTPPlaybackCommand aMTPPPBCmd, |
|
84 RResumeCmdArray& aMTPPBMPXCmd) |
|
85 { |
|
86 __FLOG(_L8("+CMTPPlaybackResumeHelper::MapMTPPBCommandToMPXCommandL")); |
|
87 |
|
88 aMTPPBMPXCmd.Reset(); |
|
89 iIfParepareArray = EFalse; |
|
90 |
|
91 switch ( aMTPPPBCmd ) |
|
92 { |
|
93 case EPlaybackCmdInitObject: |
|
94 { |
|
95 HandlePlaybackCmdInitObject( aMTPPBMPXCmd ); |
|
96 } |
|
97 break; |
|
98 case EPlaybackCmdInitIndex: |
|
99 { |
|
100 HandlePlaybackCmdInitIndex( aMTPPBMPXCmd ); |
|
101 } |
|
102 break; |
|
103 case EPlaybackCmdPlay: |
|
104 { |
|
105 HandlePlaybackCmdPlay( aMTPPBMPXCmd ); |
|
106 } |
|
107 break; |
|
108 case EPlaybackCmdPause: |
|
109 { |
|
110 HandlePlaybackCmdPause( aMTPPBMPXCmd ); |
|
111 } |
|
112 break; |
|
113 case EPlaybackCmdSkip: |
|
114 { |
|
115 HandlePlaybackCmdSkip( aMTPPBMPXCmd ); |
|
116 } |
|
117 break; |
|
118 case EPlaybackCmdSeekForward: |
|
119 { |
|
120 HandlePlaybackCmdSeekForward( aMTPPBMPXCmd ); |
|
121 } |
|
122 break; |
|
123 case EPlaybackCmdSeekBackward: |
|
124 { |
|
125 HandlePlaybackCmdSeekBackward( aMTPPBMPXCmd ); |
|
126 } |
|
127 break; |
|
128 case EPlaybackCmdSetPosition: |
|
129 { |
|
130 HandlePlaybackCmdSetPosition( aMTPPBMPXCmd ); |
|
131 } |
|
132 break; |
|
133 default: |
|
134 break; |
|
135 } |
|
136 |
|
137 __FLOG(_L8("-CMTPPlaybackResumeHelper::MapPlaybackControlCommandL")); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CMTPPlaybackResumeHelper::CMTPPlaybackResumeHelper |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 CMTPPlaybackResumeHelper::CMTPPlaybackResumeHelper( |
|
145 CMTPPlaybackControlImpl& aControlImpl ) |
|
146 : iMTPPlaybackControl( aControlImpl ) |
|
147 { |
|
148 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CMTPPlaybackResumeHelper::HandlePlaybackCmdInitObjectL |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CMTPPlaybackResumeHelper::HandlePlaybackCmdInitObject( RResumeCmdArray& aMTPPBMPXCmdArray ) |
|
156 { |
|
157 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
158 { |
|
159 case EPbStatePlaying: |
|
160 { |
|
161 TMPXComandElement command = { EPbCmdPlay, EPbStatePlaying }; |
|
162 aMTPPBMPXCmdArray.Append( command ); |
|
163 } |
|
164 break; |
|
165 default: |
|
166 break; |
|
167 } |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CMTPPlaybackResumeHelper::HandlePlaybackCmdInitObjectL |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CMTPPlaybackResumeHelper::HandlePlaybackCmdInitIndex( RResumeCmdArray& aMTPPBMPXCmdArray ) |
|
175 { |
|
176 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
177 { |
|
178 case EPbStatePlaying: |
|
179 { |
|
180 TMPXComandElement command = { EPbCmdPlay, EPbStatePlaying }; |
|
181 aMTPPBMPXCmdArray.Append( command ); |
|
182 } |
|
183 break; |
|
184 default: |
|
185 break; |
|
186 } |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CMTPPlaybackResumeHelper::HandlePlaybackCmdPlayL |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CMTPPlaybackResumeHelper::HandlePlaybackCmdPlay(RResumeCmdArray& aMTPPBMPXCmdArray ) |
|
194 { |
|
195 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
196 { |
|
197 case EPbStatePaused: |
|
198 case EPbStateStopped: |
|
199 case EPbStateInitialised: |
|
200 { |
|
201 TMPXComandElement command = { EPbCmdPlay, EPbStatePlaying }; |
|
202 aMTPPBMPXCmdArray.Append( command ); |
|
203 } |
|
204 break; |
|
205 case EPbStateSeekingBackward: |
|
206 case EPbStateSeekingForward: |
|
207 { |
|
208 if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePlaying ) |
|
209 { |
|
210 TMPXComandElement tmp = { EPbCmdStopSeeking, EPbStatePlaying }; |
|
211 aMTPPBMPXCmdArray.Append( tmp ); |
|
212 } |
|
213 else if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePaused ) |
|
214 { |
|
215 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePaused }; |
|
216 aMTPPBMPXCmdArray.Append( command ); |
|
217 TMPXComandElement command1 = { EPbCmdPlay, EPbStatePlaying }; |
|
218 aMTPPBMPXCmdArray.Append( command1 ); |
|
219 } |
|
220 } |
|
221 break; |
|
222 default: |
|
223 break; |
|
224 } |
|
225 } |
|
226 |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CMTPPlaybackResumeHelper::HandlePlaybackCmdPauseL |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 void CMTPPlaybackResumeHelper::HandlePlaybackCmdPause( RResumeCmdArray& aMTPPBMPXCmdArray ) |
|
233 { |
|
234 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
235 { |
|
236 case EPbStatePlaying: |
|
237 { |
|
238 TMPXComandElement command = { EPbCmdPlayPause, EPbStatePaused }; |
|
239 aMTPPBMPXCmdArray.Append( command ); |
|
240 } |
|
241 break; |
|
242 case EPbStateSeekingBackward: |
|
243 case EPbStateSeekingForward: |
|
244 { |
|
245 if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePaused ) |
|
246 { |
|
247 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePaused }; |
|
248 aMTPPBMPXCmdArray.Append( command ); |
|
249 } |
|
250 else if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePlaying ) |
|
251 { |
|
252 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePlaying }; |
|
253 aMTPPBMPXCmdArray.Append( command ); |
|
254 TMPXComandElement command1 = { EPbCmdPlayPause, EPbStatePaused }; |
|
255 aMTPPBMPXCmdArray.Append( command1 ); |
|
256 } |
|
257 } |
|
258 break; |
|
259 default: |
|
260 break; |
|
261 } |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CMTPPlaybackResumeHelper::HandlePlaybackCmdSeekForwardL |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CMTPPlaybackResumeHelper::HandlePlaybackCmdSeekForward( RResumeCmdArray& aMTPPBMPXCmd ) |
|
269 { |
|
270 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
271 { |
|
272 case EPbStatePlaying: |
|
273 case EPbStatePaused: |
|
274 { |
|
275 TMPXComandElement command = { EPbCmdStartSeekForward, EPbStateSeekingForward }; |
|
276 aMTPPBMPXCmd.Append( command ); |
|
277 } |
|
278 break; |
|
279 case EPbStateInitialised: |
|
280 { |
|
281 TMPXComandElement command = { EPbCmdPlay, EPbStatePlaying }; |
|
282 aMTPPBMPXCmd.Append( command ); |
|
283 TMPXComandElement command1 = { EPbCmdStartSeekForward, EPbStateSeekingForward }; |
|
284 aMTPPBMPXCmd.Append( command1 ); |
|
285 } |
|
286 break; |
|
287 case EPbStateSeekingBackward: |
|
288 { |
|
289 if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePaused ) |
|
290 { |
|
291 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePaused }; |
|
292 aMTPPBMPXCmd.Append( command ); |
|
293 TMPXComandElement command1 = { EPbCmdStartSeekForward, EPbStateSeekingForward }; |
|
294 aMTPPBMPXCmd.Append( command1 ); |
|
295 } |
|
296 else if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePlaying ) |
|
297 { |
|
298 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePlaying }; |
|
299 aMTPPBMPXCmd.Append( command ); |
|
300 TMPXComandElement command1 = { EPbCmdStartSeekForward, EPbStateSeekingForward }; |
|
301 aMTPPBMPXCmd.Append( command1 ); |
|
302 } |
|
303 } |
|
304 break; |
|
305 default: |
|
306 break; |
|
307 } |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // CMTPPlaybackResumeHelper::HandlePlaybackCmdSeekBackwardL |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 void CMTPPlaybackResumeHelper::HandlePlaybackCmdSeekBackward( RResumeCmdArray& aMTPPBMPXCmd ) |
|
315 { |
|
316 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
317 { |
|
318 case EPbStatePlaying: |
|
319 case EPbStatePaused: |
|
320 { |
|
321 TMPXComandElement command = { EPbCmdStartSeekBackward, EPbStateSeekingBackward }; |
|
322 aMTPPBMPXCmd.Append( command ); |
|
323 } |
|
324 break; |
|
325 case EPbStateSeekingForward: |
|
326 { |
|
327 if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePaused ) |
|
328 { |
|
329 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePaused }; |
|
330 aMTPPBMPXCmd.Append( command ); |
|
331 TMPXComandElement command1 = { EPbCmdStartSeekBackward, EPbStateSeekingBackward }; |
|
332 aMTPPBMPXCmd.Append( command1 ); |
|
333 } |
|
334 else if ( MTPPlaybackControlImpl().PreviousState() == EPbStatePlaying ) |
|
335 { |
|
336 TMPXComandElement command = { EPbCmdStopSeeking, EPbStatePlaying }; |
|
337 aMTPPBMPXCmd.Append( command ); |
|
338 TMPXComandElement command1 = { EPbCmdStartSeekBackward, EPbStateSeekingBackward }; |
|
339 aMTPPBMPXCmd.Append( command1 ); |
|
340 } |
|
341 } |
|
342 break; |
|
343 default: |
|
344 break; |
|
345 } |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CMTPPlaybackResumeHelper::HandlePlaybackCmdSkipL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 void CMTPPlaybackResumeHelper::HandlePlaybackCmdSkip( RResumeCmdArray& aMTPPBMPXCmd ) |
|
353 { |
|
354 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
355 { |
|
356 case EPbStatePlaying: |
|
357 { |
|
358 TMPXComandElement command = { EPbCmdPlay, EPbStatePlaying }; |
|
359 aMTPPBMPXCmd.Append( command ); |
|
360 } |
|
361 break; |
|
362 default: |
|
363 break; |
|
364 } |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CMTPPlaybackResumeHelper::HandlePlaybackCmdSetPositionL |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CMTPPlaybackResumeHelper::HandlePlaybackCmdSetPosition( RResumeCmdArray& aMTPPBMPXCmd ) |
|
372 { |
|
373 switch ( MTPPlaybackControlImpl().CurrentState() ) |
|
374 { |
|
375 case EPbStatePlaying: |
|
376 { |
|
377 if ( iIfParepareArray ) |
|
378 { |
|
379 TMPXComandElement command = { EPbCmdPause, EPbStatePaused }; |
|
380 aMTPPBMPXCmd.Append( command ); |
|
381 } |
|
382 else |
|
383 { |
|
384 TMPXComandElement command = { EPbCmdPlay, EPbStatePlaying }; |
|
385 aMTPPBMPXCmd.Append( command ); |
|
386 } |
|
387 } |
|
388 break; |
|
389 default: |
|
390 break; |
|
391 } |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CMTPPlaybackResumeHelper::CMTPPlaybackControlImpl |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 CMTPPlaybackControlImpl& CMTPPlaybackResumeHelper::MTPPlaybackControlImpl() |
|
399 { |
|
400 return iMTPPlaybackControl; |
|
401 } |
|
402 |