|
1 /* |
|
2 * Copyright (c) 2005-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: This class is used to play sound from file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "cmmacamerasound.h" |
|
22 |
|
23 #include <mdaaudiosampleplayer.h> |
|
24 #include <logger.h> |
|
25 #include <AudioPreference.h> |
|
26 |
|
27 //CONSTANTS |
|
28 _LIT(KMMASnapshotSound, "Z:\\System\\Sounds\\Digital\\CamcorderJavaCapture.wav"); |
|
29 _LIT(KMMAVideoSound, "Z:\\System\\Sounds\\Digital\\CamcorderJavaStart.wav"); |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMMACameraSound::CMMACameraSound |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CMMACameraSound::CMMACameraSound() |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CMMACameraSound::NewLC |
|
46 // Two-phased constructor. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CMMACameraSound* CMMACameraSound::NewLC() |
|
50 { |
|
51 CMMACameraSound* self = new(ELeave) CMMACameraSound; |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 // Destructor |
|
59 CMMACameraSound::~CMMACameraSound() |
|
60 { |
|
61 delete iActiveSchedulerWait; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMMACameraSound::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CMMACameraSound::ConstructL() |
|
70 { |
|
71 iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait(); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // PlayImageCaptureSoundL() |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CMMACameraSound::PlayImageCaptureSoundL() |
|
79 { |
|
80 CMMACameraSound* cameraSound = NewLC(); |
|
81 cameraSound->PlaySoundL(KMMASnapshotSound()); |
|
82 CleanupStack::PopAndDestroy(cameraSound); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // PlayVideoRecordSoundL() |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CMMACameraSound::PlayVideoRecordSoundL() |
|
90 { |
|
91 CMMACameraSound* cameraSound = NewLC(); |
|
92 cameraSound->PlaySoundL(KMMAVideoSound()); |
|
93 CleanupStack::PopAndDestroy(cameraSound); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // PlaySoundL() |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CMMACameraSound::PlaySoundL(const TDesC& aFileName) |
|
101 { |
|
102 iError = KErrNone; |
|
103 CMdaAudioPlayerUtility* player = |
|
104 CMdaAudioPlayerUtility::NewFilePlayerL( |
|
105 aFileName, *this, KAudioPriorityVideoRecording, |
|
106 TMdaPriorityPreference(KAudioPrefCamera), NULL); |
|
107 CleanupStack::PushL(player); |
|
108 |
|
109 //wait until init is completed |
|
110 if (!iActiveSchedulerWait->IsStarted()) |
|
111 { |
|
112 iActiveSchedulerWait->Start(); |
|
113 } |
|
114 //leave if there was error in init |
|
115 User::LeaveIfError(iError); |
|
116 |
|
117 player->Play(); |
|
118 //wait until play is completed |
|
119 if (!iActiveSchedulerWait->IsStarted()) |
|
120 { |
|
121 iActiveSchedulerWait->Start(); |
|
122 } |
|
123 //leave if there was error in play |
|
124 User::LeaveIfError(iError); |
|
125 |
|
126 //close player |
|
127 player->Close(); |
|
128 CleanupStack::PopAndDestroy(player); |
|
129 } |
|
130 |
|
131 void CMMACameraSound::MapcInitComplete(TInt aError, |
|
132 const TTimeIntervalMicroSeconds& /*aDuration*/) |
|
133 { |
|
134 iError = aError; |
|
135 if (iActiveSchedulerWait->IsStarted()) |
|
136 { |
|
137 iActiveSchedulerWait->AsyncStop(); |
|
138 } |
|
139 } |
|
140 |
|
141 void CMMACameraSound::MapcPlayComplete(TInt aError) |
|
142 { |
|
143 iError = aError; |
|
144 if (iActiveSchedulerWait->IsStarted()) |
|
145 { |
|
146 iActiveSchedulerWait->AsyncStop(); |
|
147 } |
|
148 } |
|
149 |
|
150 // End of File |