37
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Blid application arrived tone player utility.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// SYSTEM INCLUDES
|
|
20 |
|
|
21 |
// USER INCLUDES
|
|
22 |
#include "CBlidArrivedTonePayerUtility.h"
|
|
23 |
#include "bliduiconsts.h"
|
|
24 |
#include "Debug.h"
|
|
25 |
|
|
26 |
|
|
27 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
28 |
|
|
29 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
30 |
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
// CBlidArrivedTonePlayerUtility::CBlidArrivedTonePlayerUtility
|
|
33 |
// C++ default constructor can NOT contain any code, that
|
|
34 |
// might leave.
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
CBlidArrivedTonePlayerUtility::CBlidArrivedTonePlayerUtility( )
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
// CBlidArrivedTonePlayerUtility::ConstructL
|
|
43 |
// Symbian 2nd phase constructor can leave.
|
|
44 |
// -----------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
void CBlidArrivedTonePlayerUtility::ConstructL()
|
|
47 |
{
|
|
48 |
iAudioPlayer = CMdaAudioPlayerUtility::NewL(
|
|
49 |
*this,
|
|
50 |
EMdaPriorityNormal,
|
|
51 |
EMdaPriorityPreferenceTimeAndQuality );
|
|
52 |
}
|
|
53 |
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
// CBlidArrivedTonePlayerUtility::NewL
|
|
56 |
// Two-phased constructor.
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CBlidArrivedTonePlayerUtility* CBlidArrivedTonePlayerUtility::NewL( )
|
|
60 |
{
|
|
61 |
CBlidArrivedTonePlayerUtility* self = new( ELeave ) CBlidArrivedTonePlayerUtility( );
|
|
62 |
|
|
63 |
CleanupStack::PushL( self );
|
|
64 |
self->ConstructL();
|
|
65 |
CleanupStack::Pop();
|
|
66 |
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// CBlidArrivedTonePlayerUtility::~CBlidArrivedTonePlayerUtility
|
|
73 |
// Destructor
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CBlidArrivedTonePlayerUtility::~CBlidArrivedTonePlayerUtility()
|
|
77 |
{
|
|
78 |
if ( iAudioPlayer )
|
|
79 |
{
|
|
80 |
iAudioPlayer->Stop();
|
|
81 |
iAudioPlayer->Close();
|
|
82 |
}
|
|
83 |
delete iAudioPlayer;
|
|
84 |
iAudioPlayer = NULL;
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
// ---------------------------------------------------------
|
|
89 |
// CBlidArrivedTonePlayerUtility::PlayToneL
|
|
90 |
// Plays the appropriate tone
|
|
91 |
// ---------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CBlidArrivedTonePlayerUtility::PlayToneL( const TFileName& aFileName )
|
|
94 |
{
|
|
95 |
iFileName = aFileName;
|
|
96 |
CanclePayer();
|
|
97 |
iAudioPlayer->OpenFileL( aFileName );
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// From MMdaAudioPlayerCallback
|
|
102 |
// Callback when an attempt to open and initialise an audio sample
|
|
103 |
// has completed.
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CBlidArrivedTonePlayerUtility::MapcInitComplete(
|
|
107 |
TInt aError,
|
|
108 |
const TTimeIntervalMicroSeconds& aDuration )
|
|
109 |
{
|
|
110 |
if( aError == KErrNone )
|
|
111 |
{
|
|
112 |
iAudioDuration = aDuration;
|
|
113 |
if ( iAudioPlayer )
|
|
114 |
{
|
|
115 |
iAudioPlayer->Play();
|
|
116 |
}
|
|
117 |
}
|
|
118 |
// Do nothing
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// From MMdaAudioPlayerCallback
|
|
123 |
// Callback when an attempt to playback an audio sample has completed.
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
void CBlidArrivedTonePlayerUtility::MapcPlayComplete(
|
|
127 |
TInt aError )
|
|
128 |
{
|
|
129 |
if( aError == KErrNone )
|
|
130 |
{
|
|
131 |
TInt duration = I64INT( iAudioDuration.Int64() );
|
|
132 |
if( duration < KMinArrivalTime )
|
|
133 |
{
|
|
134 |
if ( iAudioPlayer )
|
|
135 |
{
|
|
136 |
CanclePayer();
|
|
137 |
TRAP_IGNORE( iAudioPlayer->OpenFileL( iFileName ) );
|
|
138 |
}
|
|
139 |
}
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
// CBlidArrivedTonePlayerUtility::CanclePayer().
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
void CBlidArrivedTonePlayerUtility::CanclePayer()
|
|
148 |
{
|
|
149 |
if ( iAudioPlayer )
|
|
150 |
{
|
|
151 |
iAudioPlayer->Stop();
|
|
152 |
iAudioPlayer->Close();
|
|
153 |
}
|
|
154 |
}
|
|
155 |
//End Of file
|
|
156 |
|