|
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: Dialog create for video preview |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <aknappui.h> |
|
21 #include "mediafilevideopreviewdialog.h" |
|
22 #include "mediafilepreview.h" |
|
23 #include <mediafilelist.rsg> |
|
24 |
|
25 |
|
26 |
|
27 /****************************************************************************** |
|
28 * class CVideoPreviewDialog |
|
29 ******************************************************************************/ |
|
30 |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CVideoPreviewDialog::ShowDialogLD |
|
34 // |
|
35 // NOTE: ExecuteLD deletes dialog object. |
|
36 // ----------------------------------------------------------------------------- |
|
37 TBool CVideoPreviewDialog::ShowDialogLD( TInt* aError ) |
|
38 { |
|
39 iError = aError; |
|
40 *iError = KErrNone; |
|
41 |
|
42 TBool ret = ExecuteLD( R_VIDEO_PREVIEW_DIALOG ); |
|
43 |
|
44 return ret; |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // Destructor |
|
49 // |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CVideoPreviewDialog::~CVideoPreviewDialog() |
|
53 { |
|
54 CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
55 |
|
56 delete iIdle; |
|
57 |
|
58 if ( iVideoHandlerCreated ) |
|
59 { |
|
60 delete iVideoHandler; |
|
61 } |
|
62 |
|
63 if ( iAvkonAppUi ) |
|
64 { |
|
65 iAvkonAppUi->RemoveFromStack( this ); |
|
66 } |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CVideoPreviewDialog::CVideoPreviewDialog |
|
72 // |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CVideoPreviewDialog::CVideoPreviewDialog( TAny* aVideoHandler ) |
|
76 { |
|
77 if ( aVideoHandler ) |
|
78 { |
|
79 iVideoHandler = static_cast<CMFVideoPreviewHandler*>( aVideoHandler ); |
|
80 //iVideoHandler = aVideoHandler; |
|
81 } |
|
82 iVideoHandlerCreated = EFalse; |
|
83 } |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CVideoPreviewDialog::NewL |
|
88 // |
|
89 // ----------------------------------------------------------------------------- |
|
90 CVideoPreviewDialog* CVideoPreviewDialog::NewL( TAny* aVideoHandler ) |
|
91 { |
|
92 CVideoPreviewDialog* self = new (ELeave) CVideoPreviewDialog( aVideoHandler ); |
|
93 CleanupStack::PushL(self); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop(self); |
|
96 |
|
97 return self; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CVideoPreviewDialog::ConstructL |
|
103 // |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CVideoPreviewDialog::ConstructL() |
|
107 { |
|
108 CCoeEnv::Static()->AddForegroundObserverL( *this ); |
|
109 |
|
110 CAknDialog::ConstructL( R_VIDEO_PREVIEW_DIALOG_MENU ); |
|
111 |
|
112 if ( !iVideoHandler ) |
|
113 { |
|
114 iVideoHandler = CMFVideoPreviewHandler::NewL(); |
|
115 iVideoHandlerCreated = ETrue; |
|
116 } |
|
117 |
|
118 iVideoHandler->SetObserver( this ); |
|
119 } |
|
120 |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CVideoPreviewDialog::SetAttrL |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CVideoPreviewDialog::SetAttrL( TInt aAttr, TInt aValue ) |
|
128 { |
|
129 iVideoHandler->SetAttrL( aAttr, aValue ); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CVideoPreviewDialog::SetAttrL |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CVideoPreviewDialog::SetAttrL( TInt aAttr, const TDesC& aValue ) |
|
139 { |
|
140 iVideoHandler->SetAttrL( aAttr, aValue ); |
|
141 } |
|
142 |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CVideoPreviewDialog::SetAttr |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CVideoPreviewDialog::SetAttrL( TInt aAttr, TAny* aValue ) |
|
150 { |
|
151 iVideoHandler->SetAttrL( aAttr, aValue ); |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CVideoPreviewDialog::PreLayoutDynInitL |
|
157 // |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CVideoPreviewDialog::PreLayoutDynInitL() |
|
161 { |
|
162 } |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CVideoPreviewDialog::PostLayoutDynInitL |
|
167 // |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CVideoPreviewDialog::PostLayoutDynInitL() |
|
171 { |
|
172 // dialog has two lines (see .rss). Listbox line id is 1 |
|
173 //CEikCaptionedControl *ctrl = Line( 1 ); |
|
174 //iVideoPreviewHandler->SetAttrL( TMFDialogUtil::EAttrDrawingWindow, (ctrl->iControl->DrawableWindow()) ); |
|
175 |
|
176 iVideoHandler->SetAttrL( TMFDialogUtil::EAttrDrawingWindow, DrawableWindow() ); |
|
177 iVideoHandler->PlayL(); |
|
178 } |
|
179 |
|
180 |
|
181 //------------------------------------------------------------------------------ |
|
182 // CVideoPreviewDialog::OkToExitL |
|
183 // |
|
184 //------------------------------------------------------------------------------ |
|
185 // |
|
186 TBool CVideoPreviewDialog::OkToExitL(TInt aButtonId) |
|
187 { |
|
188 if ( aButtonId == EEikBidCancel ) |
|
189 { |
|
190 if ( iVideoHandler->IsPlaying() ) |
|
191 { |
|
192 iVideoHandler->Stop(); |
|
193 } |
|
194 |
|
195 return ETrue; // close dialog |
|
196 } |
|
197 |
|
198 if ( aButtonId == EAknSoftkeySelect || aButtonId == EEikBidOk ) |
|
199 { |
|
200 if ( iVideoHandler->IsPlaying() ) |
|
201 { |
|
202 iVideoHandler->Stop(); |
|
203 } |
|
204 return ETrue; // close dialog |
|
205 } |
|
206 |
|
207 if ( aButtonId == EAknSoftkeyBack ) |
|
208 { |
|
209 if ( iVideoHandler->IsPlaying() ) |
|
210 { |
|
211 iVideoHandler->Stop(); |
|
212 } |
|
213 return ETrue; // close dialog |
|
214 } |
|
215 |
|
216 return CAknDialog::OkToExitL( aButtonId ); |
|
217 } |
|
218 |
|
219 |
|
220 // ---------------------------------------------------------------------------- |
|
221 // CVideoPreviewDialog::HandleResourceChange |
|
222 // |
|
223 // ---------------------------------------------------------------------------- |
|
224 // |
|
225 void CVideoPreviewDialog::HandleResourceChange(TInt aType) |
|
226 { |
|
227 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
228 { |
|
229 // handle change in layout orientation |
|
230 |
|
231 CAknDialog::HandleResourceChange( aType ); |
|
232 |
|
233 TRAP_IGNORE( iVideoHandler->SetDisplayWindowL() ); |
|
234 return; |
|
235 } |
|
236 } |
|
237 |
|
238 |
|
239 //------------------------------------------------------------------------------ |
|
240 // CVideoPreviewDialog::ProcessCommandL |
|
241 // |
|
242 // Handle commands from menu. |
|
243 //------------------------------------------------------------------------------ |
|
244 // |
|
245 void CVideoPreviewDialog::ProcessCommandL(TInt aCommandId) |
|
246 { |
|
247 HideMenu(); |
|
248 |
|
249 switch (aCommandId) |
|
250 { |
|
251 case EAknCmdExit: |
|
252 case EEikCmdExit: |
|
253 { |
|
254 // close dialog and exit calling application |
|
255 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
256 break; |
|
257 } |
|
258 |
|
259 default: |
|
260 break; |
|
261 } |
|
262 } |
|
263 |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CVideoPreviewDialog::CloseDialogWithDelayL |
|
267 // |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 void CVideoPreviewDialog::CloseDialogWithDelayL() |
|
271 { |
|
272 // close after short delay (dialog cannot be closed from this function) |
|
273 delete iIdle; |
|
274 iIdle = NULL; |
|
275 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
276 if ( iIdle ) |
|
277 { |
|
278 iIdle->Start( TCallBack( CloseDialog, this ) ); |
|
279 } |
|
280 } |
|
281 |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CVideoPreviewDialog::CloseDialogL() |
|
285 // |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CVideoPreviewDialog::CloseDialogL() |
|
289 { |
|
290 // close the dialogue immediately |
|
291 CloseDialog( this ); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CVideoPreviewDialog::CloseDialog |
|
296 // |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 TInt CVideoPreviewDialog::CloseDialog( TAny *aObj ) |
|
300 { |
|
301 CVideoPreviewDialog *dlg = (CVideoPreviewDialog*) aObj; |
|
302 |
|
303 TRAP_IGNORE( dlg->TryExitL( EAknSoftkeyBack ) ); |
|
304 |
|
305 return 0; |
|
306 } |
|
307 |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CVideoPreviewDialog::HandlePreviewEventL (from MPreviewHandlerObserver) |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CVideoPreviewDialog::HandlePreviewEventL( TInt aEvent, TInt aError ) |
|
315 { |
|
316 if ( aEvent == MPreviewHandlerObserver::EVideoPreviewComplete ) |
|
317 { |
|
318 *iError = aError; |
|
319 CVideoPreviewDialog::CloseDialogWithDelayL(); |
|
320 } |
|
321 |
|
322 if ( aEvent == MPreviewHandlerObserver::EPreviewError ) |
|
323 { |
|
324 *iError = aError; |
|
325 CVideoPreviewDialog::CloseDialogWithDelayL(); |
|
326 } |
|
327 } |
|
328 |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // CVideoPreviewDialog::HandleLosingForeground (from MCoeForegroundObserver) |
|
332 // |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CVideoPreviewDialog::HandleLosingForeground() |
|
336 { |
|
337 TRAP_IGNORE( CVideoPreviewDialog::CloseDialogWithDelayL() ); |
|
338 } |
|
339 |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CVideoPreviewDialog::HandleGainingForeground (from MCoeForegroundObserver) |
|
343 // |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CVideoPreviewDialog::HandleGainingForeground() |
|
347 { |
|
348 } |
|
349 |
|
350 // End of File |