54
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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: Class for preview audio and video
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
|
|
23 |
#include "mediafilepreview.h"
|
|
24 |
#include "mediafiledialogutils.h"
|
|
25 |
#include "mediafilelist.h"
|
|
26 |
#include "mediafilelistdebug.h"
|
|
27 |
|
|
28 |
#include <ScreensaverInternalPSKeys.h> // KPSUidScreenSaver
|
|
29 |
#include <AudioPreference.h> // KAudioPriorityPreview
|
|
30 |
#include <c3dringingtoneinterface.h> // C3DRingingToneInterface
|
|
31 |
|
|
32 |
#include <ctsydomainpskeys.h> // for phone call states
|
|
33 |
|
|
34 |
// for reading active profile settings
|
|
35 |
#include <MProfileEngine.h>
|
|
36 |
#include <MProfile.h>
|
|
37 |
#include <MProfileTones.h>
|
|
38 |
#include "TProfileToneSettings.h"
|
|
39 |
#include <MProfileExtraSettings.h>
|
|
40 |
#include <MProfile3DToneSettings.h>
|
|
41 |
#include <ProfileInternal.hrh>
|
|
42 |
#include <ProfileEngineDomainCRKeys.h> // KProEngDefaultRingingTone
|
|
43 |
|
|
44 |
|
|
45 |
/******************************************************************************
|
|
46 |
* class CMFPreviewHandlerBase
|
|
47 |
******************************************************************************/
|
|
48 |
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
// CMFPreviewHandlerBase::CMFPreviewHandlerBase
|
|
52 |
//
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CMFPreviewHandlerBase::CMFPreviewHandlerBase()
|
|
56 |
{
|
|
57 |
iMediaType = KErrNotFound;
|
|
58 |
iRingingVolume = KErrNotFound;
|
|
59 |
iRingingType = KErrNotFound;
|
|
60 |
iVibra = KErrNotFound;
|
|
61 |
i3DEffect = KErrNotFound;
|
|
62 |
i3DEcho = KErrNotFound;
|
|
63 |
iFileSize = KErrNotFound;
|
|
64 |
|
|
65 |
iFullName = NULL;
|
|
66 |
|
|
67 |
iActiveProfileRead = EFalse;
|
|
68 |
iPlayerStatus = EPlayerNotCreated;
|
|
69 |
|
|
70 |
iObserver = NULL;
|
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
// CMFPreviewHandlerBase::CMFPreviewHandlerBase
|
|
76 |
//
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
void CMFPreviewHandlerBase::ConstructL()
|
|
80 |
{
|
|
81 |
// To allow/not allow screensaver
|
|
82 |
// Errors ignored, no actions needed if API is not available
|
|
83 |
iProperty.Attach( KPSUidScreenSaver, KScreenSaverAllowScreenSaver );
|
|
84 |
|
|
85 |
User::LeaveIfError( iApaSession.Connect() );
|
|
86 |
|
|
87 |
TRAP_IGNORE( ReadDefaultToneL() );
|
|
88 |
// To keep backlight on while a video is being previewed
|
|
89 |
iBacklightTimer = CPeriodic::NewL( EPriorityLow );
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
// ----------------------------------------------------------------------------
|
|
94 |
// Destructor
|
|
95 |
//
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
CMFPreviewHandlerBase::~CMFPreviewHandlerBase()
|
|
99 |
{
|
|
100 |
delete iFullName;
|
|
101 |
iProperty.Close();
|
|
102 |
|
|
103 |
iApaSession.Close();
|
|
104 |
|
|
105 |
if ( iBacklightTimer )
|
|
106 |
{
|
|
107 |
delete iBacklightTimer;
|
|
108 |
iBacklightTimer = NULL;
|
|
109 |
}
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// CMFPreviewHandlerBase::SetAttr
|
|
115 |
//
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
void CMFPreviewHandlerBase::SetAttrL( TInt aAttr, TInt aValue )
|
|
118 |
{
|
|
119 |
switch ( aAttr )
|
|
120 |
{
|
|
121 |
case CMediaFileList::EAttrVolume:
|
|
122 |
{
|
|
123 |
iRingingVolume = aValue;
|
|
124 |
break;
|
|
125 |
}
|
|
126 |
case CMediaFileList::EAttrRingingType:
|
|
127 |
{
|
|
128 |
iRingingType = aValue;
|
|
129 |
break;
|
|
130 |
}
|
|
131 |
case CMediaFileList::EAttrVibra:
|
|
132 |
{
|
|
133 |
iVibra = aValue;
|
|
134 |
break;
|
|
135 |
}
|
|
136 |
case CMediaFileList::EAttr3DEffect:
|
|
137 |
{
|
|
138 |
i3DEffect = aValue;
|
|
139 |
break;
|
|
140 |
}
|
|
141 |
case CMediaFileList::EAttr3DEcho:
|
|
142 |
{
|
|
143 |
i3DEcho = aValue;
|
|
144 |
break;
|
|
145 |
}
|
|
146 |
case CMediaFileList::EAttrFileSize:
|
|
147 |
{
|
|
148 |
iFileSize = aValue;
|
|
149 |
break;
|
|
150 |
}
|
|
151 |
default:
|
|
152 |
{
|
|
153 |
break;
|
|
154 |
}
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
// CMFPreviewHandlerBase::Attr
|
|
161 |
//
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
TInt CMFPreviewHandlerBase::Attr( TInt aAttr )
|
|
164 |
{
|
|
165 |
TInt ret = KErrNotFound;
|
|
166 |
|
|
167 |
switch ( aAttr )
|
|
168 |
{
|
|
169 |
case CMediaFileList::EAttrVolume:
|
|
170 |
{
|
|
171 |
ret = iRingingVolume;
|
|
172 |
break;
|
|
173 |
}
|
|
174 |
case CMediaFileList::EAttrRingingType:
|
|
175 |
{
|
|
176 |
ret = iRingingType;
|
|
177 |
break;
|
|
178 |
}
|
|
179 |
case CMediaFileList::EAttrVibra:
|
|
180 |
{
|
|
181 |
ret = iVibra;
|
|
182 |
break;
|
|
183 |
}
|
|
184 |
case CMediaFileList::EAttr3DEffect:
|
|
185 |
{
|
|
186 |
ret = i3DEffect;
|
|
187 |
break;
|
|
188 |
}
|
|
189 |
case CMediaFileList::EAttr3DEcho:
|
|
190 |
{
|
|
191 |
ret = i3DEcho;
|
|
192 |
break;
|
|
193 |
}
|
|
194 |
case CMediaFileList::EAttrFileSize:
|
|
195 |
{
|
|
196 |
ret = iFileSize;
|
|
197 |
break;
|
|
198 |
}
|
|
199 |
default:
|
|
200 |
{
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
}
|
|
204 |
|
|
205 |
return ret;
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
// CMFPreviewHandlerBase::SetAttrL
|
|
211 |
//
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
void CMFPreviewHandlerBase::SetAttrL( TInt aAttr, const TDesC& aValue )
|
|
214 |
{
|
|
215 |
if ( aAttr == TMFDialogUtil::EAttrFileName )
|
|
216 |
{
|
|
217 |
delete iFullName;
|
|
218 |
iFullName = NULL;
|
|
219 |
iFullName = aValue.AllocL();
|
|
220 |
}
|
|
221 |
}
|
|
222 |
|
|
223 |
|
|
224 |
// -----------------------------------------------------------------------------
|
|
225 |
// CMFPreviewHandlerBase::SetAttr
|
|
226 |
//
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void CMFPreviewHandlerBase::SetAttrL( TInt aAttr, TAny* aValue )
|
|
230 |
{
|
|
231 |
if ( aAttr == TMFDialogUtil::EAttrDrawingWindow )
|
|
232 |
{
|
|
233 |
iWindow = static_cast<RWindow*>( aValue );
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
|
237 |
|
|
238 |
// -----------------------------------------------------------------------------
|
|
239 |
// CMFPreviewHandlerBase::SetObserver
|
|
240 |
//
|
|
241 |
// -----------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
void CMFPreviewHandlerBase::SetObserver( MPreviewHandlerObserver* aObserver )
|
|
244 |
{
|
|
245 |
iObserver = aObserver;
|
|
246 |
}
|
|
247 |
|
|
248 |
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
// CMFPreviewHandlerBase::IsCallOngoing
|
|
251 |
//
|
|
252 |
// -----------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
TBool CMFPreviewHandlerBase::IsCallOngoing()
|
|
255 |
{
|
|
256 |
TInt err = KErrNone;
|
|
257 |
TInt callState = EPSCTsyCallStateUninitialized;
|
|
258 |
|
|
259 |
err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState );
|
|
260 |
if ( err == KErrNone )
|
|
261 |
{
|
|
262 |
if( callState != EPSCTsyCallStateUninitialized &&
|
|
263 |
callState != EPSCTsyCallStateNone &&
|
|
264 |
callState != EPSCTsyCallStateDisconnecting )
|
|
265 |
{
|
|
266 |
// There was call ongoing
|
|
267 |
return ETrue;
|
|
268 |
}
|
|
269 |
}
|
|
270 |
|
|
271 |
return EFalse;
|
|
272 |
}
|
|
273 |
|
|
274 |
|
|
275 |
// -----------------------------------------------------------------------------
|
|
276 |
// CMFPreviewHandlerBase::RingingVolume
|
|
277 |
//
|
|
278 |
// -----------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
TInt CMFPreviewHandlerBase::RingingVolume()
|
|
281 |
{
|
|
282 |
const TInt KDefaultVolumeLevel = 7; // see profile.hrh for volume levels
|
|
283 |
|
|
284 |
if ( iRingingVolume != KErrNotFound )
|
|
285 |
{
|
|
286 |
return iRingingVolume;
|
|
287 |
}
|
|
288 |
|
|
289 |
if ( iActiveProfileRead )
|
|
290 |
{
|
|
291 |
return iActiveProfileRingingVolume;
|
|
292 |
}
|
|
293 |
|
|
294 |
return KDefaultVolumeLevel;
|
|
295 |
}
|
|
296 |
|
|
297 |
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
// CMFPreviewHandlerBase::RingingType
|
|
300 |
//
|
|
301 |
// -----------------------------------------------------------------------------
|
|
302 |
//
|
|
303 |
TInt CMFPreviewHandlerBase::RingingType()
|
|
304 |
{
|
|
305 |
if ( iRingingType != KErrNotFound )
|
|
306 |
{
|
|
307 |
return iRingingType;
|
|
308 |
}
|
|
309 |
|
|
310 |
if ( iActiveProfileRead )
|
|
311 |
{
|
|
312 |
return iActiveProfileRingingType;
|
|
313 |
}
|
|
314 |
|
|
315 |
return ERingingTypeRinging;
|
|
316 |
}
|
|
317 |
|
|
318 |
|
|
319 |
// -----------------------------------------------------------------------------
|
|
320 |
// CMFPreviewHandlerBase::Vibra
|
|
321 |
//
|
|
322 |
// -----------------------------------------------------------------------------
|
|
323 |
//
|
|
324 |
TInt CMFPreviewHandlerBase::Vibra()
|
|
325 |
{
|
|
326 |
if ( iVibra != KErrNotFound )
|
|
327 |
{
|
|
328 |
return iVibra;
|
|
329 |
}
|
|
330 |
|
|
331 |
if ( iActiveProfileRead )
|
|
332 |
{
|
|
333 |
return iActiveProfileVibra;
|
|
334 |
}
|
|
335 |
|
|
336 |
return 0; // in case of error vibra is off
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
// -----------------------------------------------------------------------------
|
|
341 |
// CMFPreviewHandlerBase::Echo3D
|
|
342 |
//
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
//
|
|
345 |
TInt CMFPreviewHandlerBase::Echo3D()
|
|
346 |
{
|
|
347 |
if ( i3DEcho != KErrNotFound )
|
|
348 |
{
|
|
349 |
return i3DEcho;
|
|
350 |
}
|
|
351 |
|
|
352 |
if ( iActiveProfileRead )
|
|
353 |
{
|
|
354 |
return iActiveProfile3DEcho;
|
|
355 |
}
|
|
356 |
|
|
357 |
return EProfile3DEchoOff; // from ProfileInternal.hrh
|
|
358 |
}
|
|
359 |
|
|
360 |
|
|
361 |
// -----------------------------------------------------------------------------
|
|
362 |
// CMFPreviewHandlerBase::Effect3D
|
|
363 |
//
|
|
364 |
// -----------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
TInt CMFPreviewHandlerBase::Effect3D()
|
|
367 |
{
|
|
368 |
if ( i3DEffect != KErrNotFound )
|
|
369 |
{
|
|
370 |
return i3DEffect;
|
|
371 |
}
|
|
372 |
|
|
373 |
if ( iActiveProfileRead )
|
|
374 |
{
|
|
375 |
return iActiveProfile3DEffect;
|
|
376 |
}
|
|
377 |
|
|
378 |
return EProfile3DEffectOff;
|
|
379 |
}
|
|
380 |
|
|
381 |
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
// CMFPreviewHandlerBase::ConvertVolume
|
|
384 |
//
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
//
|
|
387 |
TInt CMFPreviewHandlerBase::ConvertVolume( TInt aVolume, TInt aMaxVolume )
|
|
388 |
{
|
|
389 |
const TInt KMinVolumeLevel = 1;
|
|
390 |
const TInt KMaxVolumeLevel = 10;
|
|
391 |
|
|
392 |
TInt result = aMaxVolume * aVolume / KMaxVolumeLevel;
|
|
393 |
|
|
394 |
// if user has selected minimum volume level set HW volume 1
|
|
395 |
if ( aVolume == KMinVolumeLevel && result == 0 )
|
|
396 |
{
|
|
397 |
result = 1;
|
|
398 |
}
|
|
399 |
|
|
400 |
return result;
|
|
401 |
}
|
|
402 |
|
|
403 |
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
// CMFPreviewHandlerBase::ReadActiveProfileL
|
|
406 |
// -----------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
void CMFPreviewHandlerBase::ReadActiveProfileL()
|
|
409 |
{
|
|
410 |
iActiveProfileRead = EFalse;
|
|
411 |
|
|
412 |
MProfileEngine* profileEngine = CreateProfileEngineL();
|
|
413 |
CleanupReleasePushL( *profileEngine );
|
|
414 |
|
|
415 |
MProfile* activeProfile = profileEngine->ActiveProfileL();
|
|
416 |
CleanupReleasePushL( *activeProfile );
|
|
417 |
|
|
418 |
const MProfileTones& profileTones = activeProfile->ProfileTones();
|
|
419 |
|
|
420 |
const TProfileToneSettings& toneSettings = profileTones.ToneSettings();
|
|
421 |
iActiveProfileVibra = toneSettings.iVibratingAlert;
|
|
422 |
iActiveProfileRingingVolume = toneSettings.iRingingVolume;
|
|
423 |
iActiveProfileRingingType = toneSettings.iRingingType;
|
|
424 |
|
|
425 |
const MProfileExtraSettings& extra = activeProfile->ProfileExtraSettings();
|
|
426 |
const MProfile3DToneSettings& threeD = extra.Profile3DToneSettings();
|
|
427 |
|
|
428 |
iActiveProfile3DEffect = threeD.Effect();
|
|
429 |
iActiveProfile3DEcho = threeD.Echo();
|
|
430 |
|
|
431 |
CleanupStack::PopAndDestroy( activeProfile );
|
|
432 |
CleanupStack::PopAndDestroy( profileEngine );
|
|
433 |
|
|
434 |
iActiveProfileRead = ETrue;
|
|
435 |
}
|
|
436 |
|
|
437 |
|
|
438 |
// -----------------------------------------------------------------------------
|
|
439 |
// CMFPreviewHandlerBase::ReadDefaultToneL
|
|
440 |
// -----------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
void CMFPreviewHandlerBase::ReadDefaultToneL()
|
|
443 |
{
|
|
444 |
CRepository* cenrep = CRepository::NewLC( KCRUidProfileEngine );
|
|
445 |
|
|
446 |
User::LeaveIfError( cenrep->Get( KProEngDefaultRingingTone, iDefaultTone ) );
|
|
447 |
CleanupStack::PopAndDestroy( cenrep );
|
|
448 |
}
|
|
449 |
|
|
450 |
|
|
451 |
// -----------------------------------------------------------------------------
|
|
452 |
// CMFPreviewHandlerBase::EnableScreenSaver
|
|
453 |
//
|
|
454 |
// -----------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
void CMFPreviewHandlerBase::EnableScreenSaver( TBool aEnable )
|
|
457 |
{
|
|
458 |
if ( aEnable )
|
|
459 |
{
|
|
460 |
// allow screen saver, unless there's a call ongoing
|
|
461 |
if( !IsCallOngoing() )
|
|
462 |
{
|
|
463 |
// ignore error, no actions needed if API is not available
|
|
464 |
iProperty.Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver,
|
|
465 |
EFLScreenSaverAllowed );
|
|
466 |
}
|
|
467 |
}
|
|
468 |
else
|
|
469 |
{
|
|
470 |
iProperty.Set( KPSUidScreenSaver,
|
|
471 |
KScreenSaverAllowScreenSaver, EFLScreenSaverNotAllowed );
|
|
472 |
}
|
|
473 |
}
|
|
474 |
|
|
475 |
|
|
476 |
// -----------------------------------------------------------------------------
|
|
477 |
// CMFPreviewHandlerBase::GetDataType
|
|
478 |
//
|
|
479 |
// -----------------------------------------------------------------------------
|
|
480 |
//
|
|
481 |
TInt CMFPreviewHandlerBase::GetDataType( const TDesC& aFileName, TDataType& aDataType )
|
|
482 |
{
|
|
483 |
TUid dummyUid( KNullUid );
|
|
484 |
return iApaSession.AppForDocument( aFileName, dummyUid, aDataType );
|
|
485 |
}
|
|
486 |
|
|
487 |
|
|
488 |
// -----------------------------------------------------------------------------
|
|
489 |
// CMFPreviewHandlerBase::Panic
|
|
490 |
//
|
|
491 |
// -----------------------------------------------------------------------------
|
|
492 |
//
|
|
493 |
void CMFPreviewHandlerBase::Panic( TInt aReason )
|
|
494 |
{
|
|
495 |
_LIT( KPanicCategory, "CMFPreviewHandlerBase" );
|
|
496 |
|
|
497 |
User::Panic( KPanicCategory, aReason );
|
|
498 |
}
|
|
499 |
|
|
500 |
|
|
501 |
// -----------------------------------------------------------------------------
|
|
502 |
// CMFPreviewHandlerBase::DoResetInactivityTimer()
|
|
503 |
// (other items were commented in a header).
|
|
504 |
// -----------------------------------------------------------------------------
|
|
505 |
//
|
|
506 |
TInt CMFPreviewHandlerBase::DoResetInactivityTimer( TAny* /*aObject*/ )
|
|
507 |
{
|
|
508 |
User::ResetInactivityTime();
|
|
509 |
return KErrNone;
|
|
510 |
}
|
|
511 |
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
// CMFPreviewHandlerBase::DisableBackLight()
|
|
514 |
// (other items were commented in a header).
|
|
515 |
// -----------------------------------------------------------------------------
|
|
516 |
//
|
|
517 |
void CMFPreviewHandlerBase::DisableBackLight()
|
|
518 |
{
|
|
519 |
const TInt KResetInactivityTimerDelay = 2000000;
|
|
520 |
iBacklightTimer->Cancel(); // Just in case
|
|
521 |
// Disable backlight turn off during video preview
|
|
522 |
iBacklightTimer->Start( KResetInactivityTimerDelay,
|
|
523 |
KResetInactivityTimerDelay,
|
|
524 |
TCallBack( DoResetInactivityTimer, NULL ) );
|
|
525 |
|
|
526 |
}
|
|
527 |
|
|
528 |
|
|
529 |
/******************************************************************************
|
|
530 |
* class CMFVideoPreviewHandler
|
|
531 |
******************************************************************************/
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
// -----------------------------------------------------------------------------
|
|
536 |
// CMFVideoPreviewHandler::NewL
|
|
537 |
//
|
|
538 |
// -----------------------------------------------------------------------------
|
|
539 |
CMFVideoPreviewHandler* CMFVideoPreviewHandler::NewL()
|
|
540 |
{
|
|
541 |
CMFVideoPreviewHandler* self = new (ELeave) CMFVideoPreviewHandler();
|
|
542 |
CleanupStack::PushL( self );
|
|
543 |
self->ConstructL();
|
|
544 |
CleanupStack::Pop( self );
|
|
545 |
|
|
546 |
return self;
|
|
547 |
}
|
|
548 |
|
|
549 |
|
|
550 |
// -----------------------------------------------------------------------------
|
|
551 |
// CMFVideoPreviewHandler::CMFVideoPreviewHandler
|
|
552 |
//
|
|
553 |
// -----------------------------------------------------------------------------
|
|
554 |
//
|
|
555 |
CMFVideoPreviewHandler::CMFVideoPreviewHandler()
|
|
556 |
{
|
|
557 |
iPlayerStatus = EPlayerNotCreated;
|
|
558 |
}
|
|
559 |
|
|
560 |
|
|
561 |
// -----------------------------------------------------------------------------
|
|
562 |
// CMFVideoPreviewHandler::ConstructL
|
|
563 |
//
|
|
564 |
// -----------------------------------------------------------------------------
|
|
565 |
//
|
|
566 |
void CMFVideoPreviewHandler::ConstructL()
|
|
567 |
{
|
|
568 |
CMFPreviewHandlerBase::ConstructL();
|
|
569 |
}
|
|
570 |
|
|
571 |
|
|
572 |
// ----------------------------------------------------------------------------
|
|
573 |
// Destructor
|
|
574 |
//
|
|
575 |
// ----------------------------------------------------------------------------
|
|
576 |
//
|
|
577 |
CMFVideoPreviewHandler::~CMFVideoPreviewHandler()
|
|
578 |
{
|
|
579 |
Cancel();
|
|
580 |
|
|
581 |
if( iVolumeRampTimer )
|
|
582 |
{
|
|
583 |
delete iVolumeRampTimer;
|
|
584 |
}
|
|
585 |
|
|
586 |
if( iVideoPlayer )
|
|
587 |
{
|
|
588 |
delete iVideoPlayer;
|
|
589 |
}
|
|
590 |
}
|
|
591 |
|
|
592 |
|
|
593 |
// -----------------------------------------------------------------------------
|
|
594 |
// CMFVideoPreviewHandler::IsPlaying
|
|
595 |
//
|
|
596 |
// -----------------------------------------------------------------------------
|
|
597 |
TBool CMFVideoPreviewHandler::IsPlaying()
|
|
598 |
{
|
|
599 |
if ( iPlayerStatus == EPlayerNotCreated )
|
|
600 |
{
|
|
601 |
return EFalse;
|
|
602 |
}
|
|
603 |
|
|
604 |
return ETrue;
|
|
605 |
}
|
|
606 |
|
|
607 |
|
|
608 |
// -----------------------------------------------------------------------------
|
|
609 |
// CMFVideoPreviewHandler::SetDisplayWindowL
|
|
610 |
//
|
|
611 |
// -----------------------------------------------------------------------------
|
|
612 |
void CMFVideoPreviewHandler::SetDisplayWindowL()
|
|
613 |
{
|
|
614 |
if ( !iVideoPlayer )
|
|
615 |
{
|
|
616 |
return;
|
|
617 |
}
|
|
618 |
|
|
619 |
if ( !iWindow )
|
|
620 |
{
|
|
621 |
return; // no screen for showing video
|
|
622 |
}
|
|
623 |
|
|
624 |
// Screen and clip rectangles to window dimensions
|
|
625 |
TPoint wndPosition( iWindow->AbsPosition() );
|
|
626 |
TSize wndSize( iWindow->Size() );
|
|
627 |
|
|
628 |
TRect wndRect( wndPosition, wndSize );
|
|
629 |
|
|
630 |
iVideoPlayer->SetDisplayWindowL( CCoeEnv::Static()->WsSession(),
|
|
631 |
*(CCoeEnv::Static()->ScreenDevice()),
|
|
632 |
*iWindow,
|
|
633 |
wndRect,
|
|
634 |
wndRect );
|
|
635 |
}
|
|
636 |
|
|
637 |
// -----------------------------------------------------------------------------
|
|
638 |
// CMFVideoPreviewHandler::PlayL
|
|
639 |
//
|
|
640 |
// -----------------------------------------------------------------------------
|
|
641 |
void CMFVideoPreviewHandler::PlayL()
|
|
642 |
{
|
|
643 |
Cancel(); // stop previous playing
|
|
644 |
|
|
645 |
if ( !iFullName || iFullName->Des().Length() == 0 )
|
|
646 |
{
|
|
647 |
User::Leave( KErrNotFound );
|
|
648 |
}
|
|
649 |
|
|
650 |
if ( !iWindow )
|
|
651 |
{
|
|
652 |
return; // no screen for showing video
|
|
653 |
}
|
|
654 |
|
|
655 |
TRAP_IGNORE( ReadActiveProfileL() );
|
|
656 |
|
|
657 |
// Screen and clip rectangles to window dimensions
|
|
658 |
TPoint wndPosition( iWindow->AbsPosition() );
|
|
659 |
TSize wndSize( iWindow->Size() );
|
|
660 |
|
|
661 |
// iY and iHeight should be even numbers
|
|
662 |
if( wndPosition.iY % 2 )
|
|
663 |
{
|
|
664 |
wndPosition.iY = wndPosition.iY + 1;
|
|
665 |
wndSize.iHeight = wndSize.iHeight - 1;
|
|
666 |
}
|
|
667 |
if( wndSize.iHeight % 2 )
|
|
668 |
{
|
|
669 |
wndSize.iHeight = wndSize.iHeight - 1;
|
|
670 |
}
|
|
671 |
|
|
672 |
TRect wndRect( wndPosition, wndSize );
|
|
673 |
|
|
674 |
|
|
675 |
// check video file
|
|
676 |
TDataType dataType;
|
|
677 |
TInt err = GetDataType( iFullName->Des(), dataType );
|
|
678 |
if ( err != KErrNone )
|
|
679 |
{
|
|
680 |
User::Leave( err );
|
|
681 |
}
|
|
682 |
|
|
683 |
TInt vibra = Vibra();
|
|
684 |
TMdaPriorityPreference pref = (TMdaPriorityPreference) KAudioPrefRingFilePreview;
|
|
685 |
if ( vibra )
|
|
686 |
{
|
|
687 |
pref = (TMdaPriorityPreference) KAudioPrefRingFilePreviewVibra;
|
|
688 |
}
|
|
689 |
|
|
690 |
delete iVideoPlayer;
|
|
691 |
iVideoPlayer = NULL;
|
|
692 |
|
|
693 |
iVideoPlayer = CVideoPlayerUtility::NewL ( *this, KAudioPriorityPreview, pref,
|
|
694 |
CCoeEnv::Static()->WsSession(),
|
|
695 |
*(CCoeEnv::Static()->ScreenDevice()),
|
|
696 |
*iWindow,
|
|
697 |
wndRect,
|
|
698 |
wndRect );
|
|
699 |
|
|
700 |
iVideoPlayer->OpenFileL( iFullName->Des() );
|
|
701 |
|
|
702 |
iPlayerStatus = EPlayerInitializing;
|
|
703 |
|
|
704 |
EnableScreenSaver( EFalse ); // do not allow screen saver while playing
|
|
705 |
DisableBackLight();
|
|
706 |
|
|
707 |
#ifdef _DEBUG
|
|
708 |
User::InfoPrint( iFullName->Des() );
|
|
709 |
FLOG( _L("CMFVideoPreviewHandler::PlayL '%S'"), &iFullName->Des() );
|
|
710 |
#endif
|
|
711 |
|
|
712 |
}
|
|
713 |
|
|
714 |
|
|
715 |
// -----------------------------------------------------------------------------
|
|
716 |
// CMFVideoPreviewHandler::Stop
|
|
717 |
//
|
|
718 |
// -----------------------------------------------------------------------------
|
|
719 |
void CMFVideoPreviewHandler::Stop()
|
|
720 |
{
|
|
721 |
Cancel();
|
|
722 |
}
|
|
723 |
|
|
724 |
|
|
725 |
// -----------------------------------------------------------------------------
|
|
726 |
// CMFVideoPreviewHandler::Cancel
|
|
727 |
//
|
|
728 |
// -----------------------------------------------------------------------------
|
|
729 |
//
|
|
730 |
void CMFVideoPreviewHandler::Cancel()
|
|
731 |
{
|
|
732 |
TBool isPlaying = EFalse;
|
|
733 |
|
|
734 |
if( iVolumeRampTimer )
|
|
735 |
{
|
|
736 |
iVolumeRampTimer->Cancel();
|
|
737 |
}
|
|
738 |
|
|
739 |
if( iVideoPlayer )
|
|
740 |
{
|
|
741 |
isPlaying = ETrue;
|
|
742 |
|
|
743 |
if ( iPlayerStatus == EPlayerPlaying )
|
|
744 |
{
|
|
745 |
iVideoPlayer->Stop();
|
|
746 |
}
|
|
747 |
iVideoPlayer->Close();
|
|
748 |
|
|
749 |
delete iVideoPlayer;
|
|
750 |
iVideoPlayer = NULL;
|
|
751 |
}
|
|
752 |
|
|
753 |
if ( isPlaying )
|
|
754 |
{
|
|
755 |
User::InfoPrint( _L("cancel video") );
|
|
756 |
|
|
757 |
EnableScreenSaver( ETrue );
|
|
758 |
iBacklightTimer->Cancel();
|
|
759 |
}
|
|
760 |
|
|
761 |
iPlayerStatus = EPlayerNotCreated;
|
|
762 |
}
|
|
763 |
|
|
764 |
|
|
765 |
// -----------------------------------------------------------------------------
|
|
766 |
// CMFVideoPreviewHandler::SetRingingType
|
|
767 |
//
|
|
768 |
// -----------------------------------------------------------------------------
|
|
769 |
//
|
|
770 |
void CMFVideoPreviewHandler::SetRingingType( TInt aRingingType )
|
|
771 |
{
|
|
772 |
const TInt KMinVolumeLevel = 1;
|
|
773 |
const TInt KAscendingVolumeRampInterval = 3000000; // 3 seconds
|
|
774 |
|
|
775 |
if ( aRingingType == ERingingTypeAscending )
|
|
776 |
{
|
|
777 |
if ( !iVolumeRampTimer )
|
|
778 |
{
|
|
779 |
iVolumeRampTimer = CPeriodic::New( CActive::EPriorityStandard );
|
|
780 |
}
|
|
781 |
|
|
782 |
if ( iVolumeRampTimer && !iVolumeRampTimer->IsActive() )
|
|
783 |
{
|
|
784 |
TCallBack cb( VolumeRampTimerCallback, this );
|
|
785 |
iRampedVolume = KMinVolumeLevel;
|
|
786 |
iVolumeRampTimer->Start( KAscendingVolumeRampInterval,
|
|
787 |
KAscendingVolumeRampInterval, cb );
|
|
788 |
}
|
|
789 |
}
|
|
790 |
}
|
|
791 |
|
|
792 |
|
|
793 |
// -----------------------------------------------------------------------------
|
|
794 |
// CMFVideoPreviewHandler::ConvertVolume
|
|
795 |
//
|
|
796 |
// -----------------------------------------------------------------------------
|
|
797 |
//
|
|
798 |
TInt CMFVideoPreviewHandler::ConvertVolume( TInt aVolume )
|
|
799 |
{
|
|
800 |
if ( !iVideoPlayer )
|
|
801 |
{
|
|
802 |
return 0;
|
|
803 |
}
|
|
804 |
|
|
805 |
TInt result = 0;
|
|
806 |
TBool audioEnabled = EFalse;
|
|
807 |
|
|
808 |
TRAP_IGNORE( audioEnabled = iVideoPlayer->AudioEnabledL() );
|
|
809 |
|
|
810 |
if ( audioEnabled )
|
|
811 |
{
|
|
812 |
result = CMFPreviewHandlerBase::ConvertVolume( aVolume, iVideoPlayer->MaxVolume() );
|
|
813 |
|
|
814 |
// if user has selected silent ringing type or beeb once, set volume off
|
|
815 |
TInt ringingType = RingingType();
|
|
816 |
if ( ringingType == ERingingTypeSilent || ringingType == ERingingTypeBeepOnce )
|
|
817 |
{
|
|
818 |
result = 0;
|
|
819 |
}
|
|
820 |
}
|
|
821 |
|
|
822 |
return result;
|
|
823 |
}
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
// -----------------------------------------------------------------------------
|
|
828 |
// CMFVideoPreviewHandler::VolumeRampTimerCallback
|
|
829 |
//
|
|
830 |
// -----------------------------------------------------------------------------
|
|
831 |
//
|
|
832 |
TInt CMFVideoPreviewHandler::VolumeRampTimerCallback( TAny* aObj )
|
|
833 |
{
|
|
834 |
return static_cast<CMFVideoPreviewHandler*>( aObj )->VolumeRamp();
|
|
835 |
}
|
|
836 |
|
|
837 |
|
|
838 |
// -----------------------------------------------------------------------------
|
|
839 |
// CMFVideoPreviewHandler::VolumeRamp
|
|
840 |
//
|
|
841 |
// -----------------------------------------------------------------------------
|
|
842 |
//
|
|
843 |
TInt CMFVideoPreviewHandler::VolumeRamp()
|
|
844 |
{
|
|
845 |
const TInt KPhoneVideoVolumeRampStep = 1;
|
|
846 |
|
|
847 |
TInt ringingVolume = RingingVolume();
|
|
848 |
if ( iRampedVolume < ringingVolume )
|
|
849 |
{
|
|
850 |
iRampedVolume = iRampedVolume + KPhoneVideoVolumeRampStep;
|
|
851 |
if ( iRampedVolume >= ringingVolume )
|
|
852 |
{
|
|
853 |
// target volume level reached
|
|
854 |
iRampedVolume = ringingVolume;
|
|
855 |
iVolumeRampTimer->Cancel();
|
|
856 |
}
|
|
857 |
}
|
|
858 |
|
|
859 |
TRAP_IGNORE( iVideoPlayer->SetVolumeL( ConvertVolume( iRampedVolume ) ) );
|
|
860 |
|
|
861 |
return KErrNone;
|
|
862 |
}
|
|
863 |
|
|
864 |
|
|
865 |
// -----------------------------------------------------------------------------
|
|
866 |
// CMFVideoPreviewHandler::MvpuoOpenComplete (from MVidePlayerUtilityObserver)
|
|
867 |
//
|
|
868 |
// -----------------------------------------------------------------------------
|
|
869 |
//
|
|
870 |
void CMFVideoPreviewHandler::MvpuoOpenComplete( TInt aError )
|
|
871 |
{
|
|
872 |
__ASSERT_DEBUG( iPlayerStatus == EPlayerInitializing, Panic( KErrGeneral ) );
|
|
873 |
|
|
874 |
if ( aError )
|
|
875 |
{
|
|
876 |
Cancel();
|
|
877 |
|
|
878 |
if ( iObserver )
|
|
879 |
{
|
|
880 |
TInt event = MPreviewHandlerObserver::EPreviewError;
|
|
881 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
882 |
}
|
|
883 |
}
|
|
884 |
else
|
|
885 |
{
|
|
886 |
iVideoPlayer->Prepare();
|
|
887 |
}
|
|
888 |
}
|
|
889 |
|
|
890 |
|
|
891 |
// -----------------------------------------------------------------------------
|
|
892 |
// CMFVideoPreviewHandler::MvpuoPrepareComplete (from MVidePlayerUtilityObserver)
|
|
893 |
//
|
|
894 |
// -----------------------------------------------------------------------------
|
|
895 |
//
|
|
896 |
void CMFVideoPreviewHandler::MvpuoPrepareComplete( TInt aError )
|
|
897 |
{
|
|
898 |
const TInt KMinVolumeLevel = 1;
|
|
899 |
|
|
900 |
__ASSERT_DEBUG( iPlayerStatus == EPlayerInitializing, Panic( KErrGeneral ) );
|
|
901 |
|
|
902 |
if ( aError != KErrNone )
|
|
903 |
{
|
|
904 |
Cancel();
|
|
905 |
|
|
906 |
if ( iObserver )
|
|
907 |
{
|
|
908 |
TInt event = MPreviewHandlerObserver::EPreviewError;
|
|
909 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
910 |
}
|
|
911 |
return;
|
|
912 |
}
|
|
913 |
|
|
914 |
iPlayerStatus = EPlayerInitialized;
|
|
915 |
|
|
916 |
TInt ringingType = RingingType();
|
|
917 |
TInt ringingVolume = RingingVolume();
|
|
918 |
TInt vibra = Vibra();
|
|
919 |
|
|
920 |
|
|
921 |
SetRingingType( ringingType );
|
|
922 |
|
|
923 |
TInt startVolume = KMinVolumeLevel;
|
|
924 |
if ( ringingType != ERingingTypeAscending )
|
|
925 |
{
|
|
926 |
startVolume = ConvertVolume( ringingVolume );
|
|
927 |
}
|
|
928 |
else
|
|
929 |
{
|
|
930 |
// Ascending starts from minimum volume level
|
|
931 |
startVolume = ConvertVolume( KMinVolumeLevel );
|
|
932 |
}
|
|
933 |
TRAP_IGNORE( iVideoPlayer->SetVolumeL( startVolume ) );
|
|
934 |
|
|
935 |
TMdaPriorityPreference pref = (TMdaPriorityPreference) KAudioPrefRingFilePreview;
|
|
936 |
if ( vibra )
|
|
937 |
{
|
|
938 |
pref = (TMdaPriorityPreference) KAudioPrefRingFilePreviewVibra;
|
|
939 |
}
|
|
940 |
|
|
941 |
// Unfortunately SetPriorityL uses always priority/preference
|
|
942 |
// settings which are given in videoPlayer constructor and ONLY
|
|
943 |
// after that sets SetPriorityL parameter to its member data
|
|
944 |
// which leads to a situation that we need to make SetPriorityL
|
|
945 |
// call twice to make new settings effect.
|
|
946 |
TRAP_IGNORE( iVideoPlayer->SetPriorityL( KAudioPriorityPreview, pref ) );
|
|
947 |
TRAP_IGNORE( iVideoPlayer->SetPriorityL( KAudioPriorityPreview, pref ) );
|
|
948 |
|
|
949 |
iVideoPlayer->Play();
|
|
950 |
iPlayerStatus = EPlayerPlaying;
|
|
951 |
}
|
|
952 |
|
|
953 |
|
|
954 |
// -----------------------------------------------------------------------------
|
|
955 |
// CMFVideoPreviewHandler::MvpuoPlayComplete (from MVidePlayerUtilityObserver)
|
|
956 |
//
|
|
957 |
// -----------------------------------------------------------------------------
|
|
958 |
//
|
|
959 |
void CMFVideoPreviewHandler::MvpuoPlayComplete( TInt aError )
|
|
960 |
{
|
|
961 |
__ASSERT_DEBUG( iPlayerStatus == EPlayerPlaying, Panic( KErrGeneral ) );
|
|
962 |
|
|
963 |
if ( aError != KErrNone )
|
|
964 |
{
|
|
965 |
Cancel();
|
|
966 |
|
|
967 |
if ( iObserver )
|
|
968 |
{
|
|
969 |
TInt event = MPreviewHandlerObserver::EVideoPreviewComplete;
|
|
970 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
971 |
}
|
|
972 |
return;
|
|
973 |
}
|
|
974 |
|
|
975 |
TInt ringingType = RingingType();
|
|
976 |
if( ringingType != ERingingTypeRingOnce )
|
|
977 |
{
|
|
978 |
iVideoPlayer->Play();
|
|
979 |
}
|
|
980 |
else
|
|
981 |
{
|
|
982 |
Cancel();
|
|
983 |
if ( iObserver )
|
|
984 |
{
|
|
985 |
TInt event = MPreviewHandlerObserver::EVideoPreviewComplete;
|
|
986 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
987 |
}
|
|
988 |
}
|
|
989 |
}
|
|
990 |
|
|
991 |
|
|
992 |
// -----------------------------------------------------------------------------
|
|
993 |
// CMFVideoPreviewHandler::MvpuoFrameReady (from MVidePlayerUtilityObserver)
|
|
994 |
//
|
|
995 |
// -----------------------------------------------------------------------------
|
|
996 |
//
|
|
997 |
void CMFVideoPreviewHandler::MvpuoFrameReady( CFbsBitmap& /*aFrame*/,TInt /*aError*/ )
|
|
998 |
{
|
|
999 |
}
|
|
1000 |
|
|
1001 |
|
|
1002 |
// -----------------------------------------------------------------------------
|
|
1003 |
// CMFVideoPreviewHandler::MvpuoEvent (from MVidePlayerUtilityObserver)
|
|
1004 |
//
|
|
1005 |
// -----------------------------------------------------------------------------
|
|
1006 |
//
|
|
1007 |
void CMFVideoPreviewHandler::MvpuoEvent( const TMMFEvent& /*aEvent*/ )
|
|
1008 |
{
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
|
|
1012 |
// -----------------------------------------------------------------------------
|
|
1013 |
// CMFVideoPreviewHandler::GetRectData
|
|
1014 |
//
|
|
1015 |
// -----------------------------------------------------------------------------
|
|
1016 |
void CMFVideoPreviewHandler::GetRectData( TRect aRect, TDes& aText )
|
|
1017 |
{
|
|
1018 |
_LIT( KFormat, "top left (%d,%d) bottom right (%d,%d)" );
|
|
1019 |
|
|
1020 |
TPoint p1 = aRect.iTl;
|
|
1021 |
TPoint p2 = aRect.iBr;
|
|
1022 |
|
|
1023 |
aText.Format( KFormat, p1.iX, p1.iY, p2.iX, p2.iY );
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
|
1029 |
/******************************************************************************
|
|
1030 |
* class CMFAudioPreviewHandler
|
|
1031 |
******************************************************************************/
|
|
1032 |
|
|
1033 |
|
|
1034 |
|
|
1035 |
// -----------------------------------------------------------------------------
|
|
1036 |
// CMFAudioPreviewHandler::NewL
|
|
1037 |
//
|
|
1038 |
// -----------------------------------------------------------------------------
|
|
1039 |
CMFAudioPreviewHandler* CMFAudioPreviewHandler::NewL()
|
|
1040 |
{
|
|
1041 |
CMFAudioPreviewHandler* self = new (ELeave) CMFAudioPreviewHandler();
|
|
1042 |
CleanupStack::PushL(self);
|
|
1043 |
self->ConstructL();
|
|
1044 |
CleanupStack::Pop(self);
|
|
1045 |
|
|
1046 |
return self;
|
|
1047 |
}
|
|
1048 |
|
|
1049 |
|
|
1050 |
// -----------------------------------------------------------------------------
|
|
1051 |
// CMFAudioPreviewHandler::CMFAudioPreviewHandler
|
|
1052 |
//
|
|
1053 |
// -----------------------------------------------------------------------------
|
|
1054 |
//
|
|
1055 |
CMFAudioPreviewHandler::CMFAudioPreviewHandler()
|
|
1056 |
{
|
|
1057 |
iAudioPlayerStatus = EPlayerNotCreated;
|
|
1058 |
iTonePlayerStatus = EPlayerNotCreated;
|
|
1059 |
}
|
|
1060 |
|
|
1061 |
|
|
1062 |
// -----------------------------------------------------------------------------
|
|
1063 |
// CMFAudioPreviewHandler::CMFAudioPreviewHandler
|
|
1064 |
//
|
|
1065 |
// -----------------------------------------------------------------------------
|
|
1066 |
//
|
|
1067 |
void CMFAudioPreviewHandler::ConstructL()
|
|
1068 |
{
|
|
1069 |
CMFPreviewHandlerBase::ConstructL();
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
|
|
1073 |
// ----------------------------------------------------------------------------
|
|
1074 |
// Destructor
|
|
1075 |
//
|
|
1076 |
// ----------------------------------------------------------------------------
|
|
1077 |
//
|
|
1078 |
CMFAudioPreviewHandler::~CMFAudioPreviewHandler()
|
|
1079 |
{
|
|
1080 |
Cancel();
|
|
1081 |
|
|
1082 |
delete iAudioPlayer;
|
|
1083 |
delete iTonePlayer;
|
|
1084 |
delete i3dRingingTonePlugin;
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
|
|
1088 |
// -----------------------------------------------------------------------------
|
|
1089 |
// CMFAudioPreviewHandler::IsPlaying
|
|
1090 |
//
|
|
1091 |
// -----------------------------------------------------------------------------
|
|
1092 |
TBool CMFAudioPreviewHandler::IsPlaying()
|
|
1093 |
{
|
|
1094 |
if ( iAudioPlayerStatus != EPlayerNotCreated )
|
|
1095 |
{
|
|
1096 |
return ETrue;
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
if ( iTonePlayerStatus != EPlayerNotCreated )
|
|
1100 |
{
|
|
1101 |
return ETrue;
|
|
1102 |
}
|
|
1103 |
|
|
1104 |
return EFalse;
|
|
1105 |
}
|
|
1106 |
|
|
1107 |
|
|
1108 |
// -----------------------------------------------------------------------------
|
|
1109 |
// CMFAudioPreviewHandler::PlayL
|
|
1110 |
//
|
|
1111 |
// -----------------------------------------------------------------------------
|
|
1112 |
void CMFAudioPreviewHandler::PlayL()
|
|
1113 |
{
|
|
1114 |
//sequence for playing a beep once sound
|
|
1115 |
_LIT8( KFileListBeepSequence, "\x00\x11\x06\x0A\x08\x73\x0A\x40\x28\x0A\xF7\
|
|
1116 |
\x05\xFC\x40\x64\x0A\x08\x40\x32\x0A\xF7\x06\x0B" );
|
|
1117 |
|
|
1118 |
// rng mime type
|
|
1119 |
_LIT( KFileListRngMimeType, "application/vnd.nokia.ringing-tone" );
|
|
1120 |
|
|
1121 |
Cancel(); // stop previous play
|
|
1122 |
|
|
1123 |
if ( !iFullName || iFullName->Des().Length() == 0 )
|
|
1124 |
{
|
|
1125 |
User::Leave( KErrNotFound );
|
|
1126 |
}
|
|
1127 |
|
|
1128 |
TRAP_IGNORE( ReadActiveProfileL() );
|
|
1129 |
|
|
1130 |
TPtrC fileName( iFullName->Des() );
|
|
1131 |
TDataType dataType;
|
|
1132 |
TInt err = GetDataType( fileName, dataType );
|
|
1133 |
if ( err == KErrNotFound )
|
|
1134 |
{
|
|
1135 |
fileName.Set( iDefaultTone );
|
|
1136 |
if ( fileName.Length() == 0 )
|
|
1137 |
{
|
|
1138 |
User::Leave( KErrNotFound );
|
|
1139 |
}
|
|
1140 |
}
|
|
1141 |
else if ( err != KErrNone )
|
|
1142 |
{
|
|
1143 |
User::Leave( err );
|
|
1144 |
}
|
|
1145 |
|
|
1146 |
TBool mimeTypeRng = EFalse;
|
|
1147 |
|
|
1148 |
if ( err == KErrNone )
|
|
1149 |
{
|
|
1150 |
if( dataType.Des().CompareF( KFileListRngMimeType ) == 0 )
|
|
1151 |
{
|
|
1152 |
mimeTypeRng = ETrue;
|
|
1153 |
}
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
TInt ringingType = RingingType();
|
|
1157 |
if ( ringingType == ERingingTypeBeepOnce )
|
|
1158 |
{
|
|
1159 |
// Active profile ringing tone is set to Beep Once
|
|
1160 |
// Don't initialize a FileSequence but use DesSequence instead
|
|
1161 |
iTonePlayer = CMdaAudioToneUtility::NewL( *this );
|
|
1162 |
iTonePlayer->PrepareToPlayDesSequence( KFileListBeepSequence() );
|
|
1163 |
iTonePlayerStatus = EPlayerInitializing;
|
|
1164 |
}
|
|
1165 |
else
|
|
1166 |
{
|
|
1167 |
if( mimeTypeRng )
|
|
1168 |
{
|
|
1169 |
//Ringingtone is a RNG-file
|
|
1170 |
iTonePlayer = CMdaAudioToneUtility::NewL( *this );
|
|
1171 |
iTonePlayer->PrepareToPlayFileSequence( fileName );
|
|
1172 |
iTonePlayerStatus = EPlayerInitializing;
|
|
1173 |
}
|
|
1174 |
else
|
|
1175 |
{
|
|
1176 |
delete iAudioPlayer;
|
|
1177 |
iAudioPlayer = NULL;
|
|
1178 |
|
|
1179 |
iAudioPlayer = CDrmPlayerUtility::NewFilePlayerL(
|
|
1180 |
fileName, *this, KAudioPriorityRingingTonePreview,
|
|
1181 |
( TMdaPriorityPreference )KAudioPrefRingFilePreview );
|
|
1182 |
|
|
1183 |
iAudioPlayerStatus = EPlayerInitializing;
|
|
1184 |
}
|
|
1185 |
}
|
|
1186 |
|
|
1187 |
EnableScreenSaver( EFalse );
|
|
1188 |
DisableBackLight();
|
|
1189 |
|
|
1190 |
#ifdef _DEBUG
|
|
1191 |
User::InfoPrint( iFullName->Des() );
|
|
1192 |
FLOG( _L("CMFAudioPreviewHandler::PlayL '%S'"), &iFullName->Des() );
|
|
1193 |
#endif
|
|
1194 |
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
|
|
1198 |
// -----------------------------------------------------------------------------
|
|
1199 |
// CMFAudioPreviewHandler::Stop
|
|
1200 |
//
|
|
1201 |
// -----------------------------------------------------------------------------
|
|
1202 |
void CMFAudioPreviewHandler::Stop()
|
|
1203 |
{
|
|
1204 |
Cancel();
|
|
1205 |
}
|
|
1206 |
|
|
1207 |
|
|
1208 |
// -----------------------------------------------------------------------------
|
|
1209 |
// CMFAudioPreviewHandler::ConvertVolume
|
|
1210 |
//
|
|
1211 |
// -----------------------------------------------------------------------------
|
|
1212 |
//
|
|
1213 |
TInt CMFAudioPreviewHandler::ConvertVolume( TInt aVolume )
|
|
1214 |
{
|
|
1215 |
TInt result = 0;
|
|
1216 |
if ( iAudioPlayer )
|
|
1217 |
{
|
|
1218 |
result = CMFPreviewHandlerBase::ConvertVolume( aVolume, iAudioPlayer->MaxVolume() );
|
|
1219 |
}
|
|
1220 |
else if ( iTonePlayer )
|
|
1221 |
{
|
|
1222 |
result = CMFPreviewHandlerBase::ConvertVolume( aVolume, iTonePlayer->MaxVolume() );
|
|
1223 |
}
|
|
1224 |
|
|
1225 |
//if user has selected silent ringing type, set volume off
|
|
1226 |
TInt ringingType = RingingType();
|
|
1227 |
if( ringingType == ERingingTypeSilent )
|
|
1228 |
{
|
|
1229 |
result = 0;
|
|
1230 |
}
|
|
1231 |
|
|
1232 |
return result;
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
|
|
1236 |
// -----------------------------------------------------------------------------
|
|
1237 |
// CMFAudioPreviewHandler::SetToneRingingType
|
|
1238 |
//
|
|
1239 |
// -----------------------------------------------------------------------------
|
|
1240 |
//
|
|
1241 |
void CMFAudioPreviewHandler::SetToneRingingType( TInt aRingingType )
|
|
1242 |
{
|
|
1243 |
const TInt KToneInterval = 1000000; // 1 second pause between tones
|
|
1244 |
const TInt KAscendingVolumeInterval = 3000000; // 3 seconds
|
|
1245 |
|
|
1246 |
if ( !iTonePlayer )
|
|
1247 |
{
|
|
1248 |
return;
|
|
1249 |
}
|
|
1250 |
|
|
1251 |
__ASSERT_DEBUG( iTonePlayerStatus == EPlayerInitialized, Panic( KErrGeneral ) );
|
|
1252 |
|
|
1253 |
|
|
1254 |
TInt ringingVolume = RingingVolume();
|
|
1255 |
|
|
1256 |
switch( aRingingType )
|
|
1257 |
{
|
|
1258 |
case ERingingTypeRinging:
|
|
1259 |
case ERingingTypeSilent:
|
|
1260 |
{
|
|
1261 |
iTonePlayer->SetRepeats( KMdaAudioToneRepeatForever,
|
|
1262 |
TTimeIntervalMicroSeconds( KToneInterval ) );
|
|
1263 |
break;
|
|
1264 |
}
|
|
1265 |
case ERingingTypeAscending:
|
|
1266 |
{
|
|
1267 |
iTonePlayer->SetRepeats( KMdaAudioToneRepeatForever,
|
|
1268 |
TTimeIntervalMicroSeconds( KToneInterval ) );
|
|
1269 |
|
|
1270 |
TInt volRamp = KAscendingVolumeInterval * ringingVolume;
|
|
1271 |
iTonePlayer->SetVolumeRamp( TTimeIntervalMicroSeconds( volRamp ) );
|
|
1272 |
break;
|
|
1273 |
}
|
|
1274 |
case ERingingTypeRingOnce:
|
|
1275 |
case ERingingTypeBeepOnce:
|
|
1276 |
{
|
|
1277 |
iTonePlayer->SetRepeats( 0, TTimeIntervalMicroSeconds( KToneInterval ) );
|
|
1278 |
break;
|
|
1279 |
}
|
|
1280 |
default:
|
|
1281 |
{
|
|
1282 |
break;
|
|
1283 |
}
|
|
1284 |
}
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
|
|
1288 |
// -----------------------------------------------------------------------------
|
|
1289 |
// CMFAudioPreviewHandler::SetAudioRingingType
|
|
1290 |
//
|
|
1291 |
// -----------------------------------------------------------------------------
|
|
1292 |
//
|
|
1293 |
void CMFAudioPreviewHandler::SetAudioRingingType( TInt aRingingType )
|
|
1294 |
{
|
|
1295 |
const TInt KToneInterval = 1000000; // 1 second pause between tones
|
|
1296 |
const TInt KAscendingVolumeInterval = 3000000; // 3 seconds
|
|
1297 |
|
|
1298 |
if ( !iAudioPlayer )
|
|
1299 |
{
|
|
1300 |
return;
|
|
1301 |
}
|
|
1302 |
|
|
1303 |
__ASSERT_DEBUG( iAudioPlayerStatus == EPlayerInitialized, Panic( KErrGeneral ) );
|
|
1304 |
|
|
1305 |
|
|
1306 |
TInt ringingVolume = RingingVolume();
|
|
1307 |
|
|
1308 |
switch( aRingingType )
|
|
1309 |
{
|
|
1310 |
case ERingingTypeRinging:
|
|
1311 |
case ERingingTypeSilent:
|
|
1312 |
{
|
|
1313 |
iAudioPlayer->SetRepeats( KMdaAudioToneRepeatForever,
|
|
1314 |
TTimeIntervalMicroSeconds( KToneInterval ) );
|
|
1315 |
break;
|
|
1316 |
}
|
|
1317 |
case ERingingTypeAscending:
|
|
1318 |
{
|
|
1319 |
iAudioPlayer->SetRepeats( KMdaAudioToneRepeatForever,
|
|
1320 |
TTimeIntervalMicroSeconds( KToneInterval ) );
|
|
1321 |
TInt volRamp = KAscendingVolumeInterval * ringingVolume;
|
|
1322 |
iAudioPlayer->SetVolumeRamp( TTimeIntervalMicroSeconds( volRamp ) );
|
|
1323 |
break;
|
|
1324 |
}
|
|
1325 |
case ERingingTypeRingOnce:
|
|
1326 |
{
|
|
1327 |
iAudioPlayer->SetRepeats( 0, TTimeIntervalMicroSeconds( KToneInterval ) );
|
|
1328 |
break;
|
|
1329 |
}
|
|
1330 |
|
|
1331 |
default:
|
|
1332 |
{
|
|
1333 |
break;
|
|
1334 |
}
|
|
1335 |
}
|
|
1336 |
}
|
|
1337 |
|
|
1338 |
|
|
1339 |
// -----------------------------------------------------------------------------
|
|
1340 |
// CMFAudioPreviewHandler::Cancel
|
|
1341 |
//
|
|
1342 |
// -----------------------------------------------------------------------------
|
|
1343 |
//
|
|
1344 |
void CMFAudioPreviewHandler::Cancel()
|
|
1345 |
{
|
|
1346 |
TBool isPlaying = EFalse;
|
|
1347 |
|
|
1348 |
if ( iAudioPlayer )
|
|
1349 |
{
|
|
1350 |
isPlaying = ETrue;
|
|
1351 |
if ( iAudioPlayerStatus == EPlayerPlayingWith3DEffect )
|
|
1352 |
{
|
|
1353 |
i3dRingingTonePlugin->Stop();
|
|
1354 |
// plugin calls AudioPlayer->Stop()
|
|
1355 |
iAudioPlayer->Close();
|
|
1356 |
}
|
|
1357 |
if ( iAudioPlayerStatus == EPlayerPlaying )
|
|
1358 |
{
|
|
1359 |
iAudioPlayer->Stop();
|
|
1360 |
iAudioPlayer->Close();
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
delete iAudioPlayer;
|
|
1364 |
iAudioPlayer = NULL;
|
|
1365 |
iAudioPlayerStatus = EPlayerNotCreated;
|
|
1366 |
}
|
|
1367 |
|
|
1368 |
if ( iTonePlayer )
|
|
1369 |
{
|
|
1370 |
isPlaying = ETrue;
|
|
1371 |
if ( iTonePlayerStatus == EPlayerPlaying )
|
|
1372 |
{
|
|
1373 |
iTonePlayer->CancelPlay();
|
|
1374 |
}
|
|
1375 |
|
|
1376 |
delete iTonePlayer;
|
|
1377 |
iTonePlayer = NULL;
|
|
1378 |
iTonePlayerStatus = EPlayerNotCreated;
|
|
1379 |
}
|
|
1380 |
|
|
1381 |
|
|
1382 |
if ( isPlaying )
|
|
1383 |
{
|
|
1384 |
//User::InfoPrint(_L("cancel"));
|
|
1385 |
EnableScreenSaver( ETrue );
|
|
1386 |
iBacklightTimer->Cancel();
|
|
1387 |
}
|
|
1388 |
}
|
|
1389 |
|
|
1390 |
|
|
1391 |
// -----------------------------------------------------------------------------
|
|
1392 |
// CMFAudioPreviewHandler::MatoPlayComplete (from MMdaAudioToneObserver)
|
|
1393 |
//
|
|
1394 |
// -----------------------------------------------------------------------------
|
|
1395 |
//
|
|
1396 |
void CMFAudioPreviewHandler::MatoPlayComplete( TInt aError )
|
|
1397 |
{
|
|
1398 |
if ( iObserver )
|
|
1399 |
{
|
|
1400 |
TInt event = MPreviewHandlerObserver::EAudioPreviewComplete;
|
|
1401 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
1402 |
}
|
|
1403 |
|
|
1404 |
Cancel();
|
|
1405 |
}
|
|
1406 |
|
|
1407 |
|
|
1408 |
// -----------------------------------------------------------------------------
|
|
1409 |
// CMFAudioPreviewHandler::MatoPrepareComplete (from MMdaAudioToneObserver)
|
|
1410 |
//
|
|
1411 |
// -----------------------------------------------------------------------------
|
|
1412 |
//
|
|
1413 |
void CMFAudioPreviewHandler::MatoPrepareComplete( TInt aError )
|
|
1414 |
{
|
|
1415 |
__ASSERT_DEBUG( iTonePlayerStatus == EPlayerInitializing, Panic( KErrGeneral ) );
|
|
1416 |
|
|
1417 |
if ( aError != KErrNone )
|
|
1418 |
{
|
|
1419 |
Cancel();
|
|
1420 |
|
|
1421 |
if ( iObserver )
|
|
1422 |
{
|
|
1423 |
TInt event = MPreviewHandlerObserver::EPreviewError;
|
|
1424 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
1425 |
}
|
|
1426 |
|
|
1427 |
return;
|
|
1428 |
}
|
|
1429 |
|
|
1430 |
TInt ringingVolume = RingingVolume();
|
|
1431 |
TInt ringingType = RingingType();
|
|
1432 |
TInt vibra = Vibra();
|
|
1433 |
|
|
1434 |
iTonePlayerStatus = EPlayerInitialized;
|
|
1435 |
SetToneRingingType( ringingType );
|
|
1436 |
iTonePlayer->SetVolume( ConvertVolume( ringingVolume ) );
|
|
1437 |
|
|
1438 |
TMdaPriorityPreference pref = (TMdaPriorityPreference) KAudioPrefRingFilePreview;
|
|
1439 |
if ( vibra )
|
|
1440 |
{
|
|
1441 |
pref = (TMdaPriorityPreference) KAudioPrefRingFilePreviewVibra;
|
|
1442 |
}
|
|
1443 |
iTonePlayer->SetPriority( KAudioPriorityPreview, pref );
|
|
1444 |
|
|
1445 |
iTonePlayer->Play();
|
|
1446 |
iTonePlayerStatus = EPlayerPlaying;
|
|
1447 |
}
|
|
1448 |
|
|
1449 |
|
|
1450 |
// -----------------------------------------------------------------------------
|
|
1451 |
// CMFAudioPreviewHandler::MdapcInitComplete (from MDrmAudioPlayerCallback)
|
|
1452 |
//
|
|
1453 |
// -----------------------------------------------------------------------------
|
|
1454 |
//
|
|
1455 |
void CMFAudioPreviewHandler::MdapcInitComplete( TInt aError,
|
|
1456 |
const TTimeIntervalMicroSeconds& /* aDuration */ )
|
|
1457 |
{
|
|
1458 |
__ASSERT_DEBUG( iAudioPlayer, Panic( KErrGeneral ) );
|
|
1459 |
|
|
1460 |
if ( aError != KErrNone )
|
|
1461 |
{
|
|
1462 |
Cancel();
|
|
1463 |
|
|
1464 |
if ( iObserver )
|
|
1465 |
{
|
|
1466 |
TInt event = MPreviewHandlerObserver::EPreviewError;
|
|
1467 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
1468 |
}
|
|
1469 |
return;
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
|
|
1473 |
TInt ringingVolume = RingingVolume();
|
|
1474 |
TInt ringingType = RingingType();
|
|
1475 |
TInt vibra = Vibra();
|
|
1476 |
TInt echo3D = Echo3D();
|
|
1477 |
TInt effect3D = Effect3D();
|
|
1478 |
|
|
1479 |
__ASSERT_DEBUG( ringingType != ERingingTypeBeepOnce,
|
|
1480 |
TMFDialogUtil::Panic( KErrGeneral ) );
|
|
1481 |
|
|
1482 |
iAudioPlayerStatus = EPlayerInitialized;
|
|
1483 |
SetAudioRingingType( ringingType );
|
|
1484 |
iAudioPlayer->SetVolume( ConvertVolume( ringingVolume ) );
|
|
1485 |
|
|
1486 |
TMdaPriorityPreference pref = (TMdaPriorityPreference) KAudioPrefRingFilePreview;
|
|
1487 |
if ( vibra )
|
|
1488 |
{
|
|
1489 |
pref = (TMdaPriorityPreference) KAudioPrefRingFilePreviewVibra;
|
|
1490 |
}
|
|
1491 |
iAudioPlayer->SetPriority( KAudioPriorityPreview, pref );
|
|
1492 |
|
|
1493 |
iAudioPlayerStatus = EPlayerPlaying;
|
|
1494 |
|
|
1495 |
if ( effect3D == EProfile3DEffectOff )
|
|
1496 |
{
|
|
1497 |
iAudioPlayer->Play(); // 3D not used
|
|
1498 |
return;
|
|
1499 |
}
|
|
1500 |
|
|
1501 |
if ( !i3dRingingTonePlugin )
|
|
1502 |
{
|
|
1503 |
TUid emptyUid = { 0 };
|
|
1504 |
TRAPD( err, i3dRingingTonePlugin = C3DRingingToneInterface::NewL( emptyUid ) );
|
|
1505 |
if ( err != KErrNone || !i3dRingingTonePlugin )
|
|
1506 |
{
|
|
1507 |
iAudioPlayer->Play();
|
|
1508 |
return;
|
|
1509 |
}
|
|
1510 |
}
|
|
1511 |
|
|
1512 |
i3dRingingTonePlugin->SetAttr( E3DRTIAttr3DEffect, effect3D );
|
|
1513 |
i3dRingingTonePlugin->SetAttr( E3DRTIAttr3DEcho, echo3D );
|
|
1514 |
i3dRingingTonePlugin->SetAttr( E3DRTIAttrDrmPlayerUtility, iAudioPlayer );
|
|
1515 |
TRAP_IGNORE( i3dRingingTonePlugin->PlayL() );
|
|
1516 |
|
|
1517 |
iAudioPlayerStatus = EPlayerPlayingWith3DEffect;
|
|
1518 |
}
|
|
1519 |
|
|
1520 |
|
|
1521 |
// -----------------------------------------------------------------------------
|
|
1522 |
// CMFAudioPreviewHandler::MdapcPlayComplete (from MDrmAudioPlayerCallback)
|
|
1523 |
//
|
|
1524 |
// -----------------------------------------------------------------------------
|
|
1525 |
//
|
|
1526 |
void CMFAudioPreviewHandler::MdapcPlayComplete( TInt aError )
|
|
1527 |
{
|
|
1528 |
if ( iObserver )
|
|
1529 |
{
|
|
1530 |
TInt event = MPreviewHandlerObserver::EAudioPreviewComplete;
|
|
1531 |
TRAP_IGNORE( iObserver->HandlePreviewEventL( event, aError ) );
|
|
1532 |
}
|
|
1533 |
|
|
1534 |
Cancel();
|
|
1535 |
}
|
|
1536 |
|
|
1537 |
|
|
1538 |
|
|
1539 |
// End of File
|