|
1 /* |
|
2 * Copyright (c) 2002 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 implements FramePositioningControl for animation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <jdebug.h> |
|
21 #include <e32base.h> |
|
22 |
|
23 #include "MIHLImageViewer.h" |
|
24 #include "cmmaanimationframepositioningcontrol.h" |
|
25 |
|
26 CMMAAnimationFramePositioningControl* |
|
27 CMMAAnimationFramePositioningControl::NewL(CMMAAnimationPlayer* aPlayer) |
|
28 { |
|
29 CMMAAnimationFramePositioningControl* self = |
|
30 new(ELeave) CMMAAnimationFramePositioningControl(aPlayer); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CMMAAnimationFramePositioningControl:: |
|
35 CMMAAnimationFramePositioningControl(CMMAAnimationPlayer* aPlayer) |
|
36 : CMMAFramePositioningControl(aPlayer), iPlayer(aPlayer) |
|
37 { |
|
38 DEBUG("MMA:CMMAAnimationFramePositioningControl::CMMAAnimationFramePositioningControl"); |
|
39 } |
|
40 |
|
41 CMMAAnimationFramePositioningControl::~CMMAAnimationFramePositioningControl() |
|
42 { |
|
43 DEBUG("MMA:CMMAAnimationFramePositioningControl::~CMMAAnimationFramePositioningControl"); |
|
44 } |
|
45 |
|
46 TInt CMMAAnimationFramePositioningControl::SeekL(TInt aFrameNumber) |
|
47 { |
|
48 DEBUG("CMMAAnimationFramePositioningControl::SeekL"); |
|
49 MIHLImageViewer* viewer = iPlayer->Viewer(); |
|
50 if (!viewer) |
|
51 { |
|
52 return KErrNotFound; |
|
53 } |
|
54 TInt frameNumber = FindFrame(viewer, aFrameNumber); |
|
55 TInt64 mediaTime = iPlayer->MediaTimeForFrame(frameNumber); |
|
56 // adjust wanted media time to get right frame (equal value returns one too small) |
|
57 mediaTime++; |
|
58 iPlayer->SetMediaTimeL(&mediaTime); |
|
59 frameNumber = viewer->AnimationFrame(); |
|
60 return frameNumber; |
|
61 } |
|
62 |
|
63 TInt CMMAAnimationFramePositioningControl::SkipL(TInt aFramesToSkip) |
|
64 { |
|
65 DEBUG("CMMAAnimationFramePositioningControl::SkipL"); |
|
66 MIHLImageViewer* viewer = iPlayer->Viewer(); |
|
67 if (!viewer) |
|
68 { |
|
69 return KErrNotFound; |
|
70 } |
|
71 |
|
72 TInt frameNumber = viewer->AnimationFrame(); |
|
73 |
|
74 SeekL(frameNumber + aFramesToSkip); |
|
75 |
|
76 // Calculate number of frames skipped |
|
77 return viewer->AnimationFrame() - frameNumber; |
|
78 } |
|
79 |
|
80 void CMMAAnimationFramePositioningControl::MapFrameToTimeL( |
|
81 TInt aFrameNumber, |
|
82 TInt64* aMediaTime) |
|
83 { |
|
84 DEBUG("CMMAAnimationFramePositioningControl::MapFrameToTimeL"); |
|
85 MIHLImageViewer* viewer = iPlayer->Viewer(); |
|
86 if (!viewer || (aFrameNumber < 0) || |
|
87 (aFrameNumber >= viewer->AnimationFrameCount())) |
|
88 { |
|
89 *aMediaTime = KErrNotFound; |
|
90 } |
|
91 else |
|
92 { |
|
93 *aMediaTime = iPlayer->MediaTimeForFrame(aFrameNumber); |
|
94 } |
|
95 } |
|
96 TInt CMMAAnimationFramePositioningControl::MapTimeToFrameL( |
|
97 TInt64* aMediaTime) |
|
98 { |
|
99 DEBUG("CMMAAnimationFramePositioningControl::MapTimeToFrameL"); |
|
100 MIHLImageViewer* viewer = iPlayer->Viewer(); |
|
101 TInt64 duration; |
|
102 iPlayer->GetDuration(&duration); |
|
103 if (!viewer || (*aMediaTime < 0) || |
|
104 (duration == KErrNotFound)) |
|
105 { |
|
106 return KErrNotFound; |
|
107 } |
|
108 return iPlayer->FindFrame(*aMediaTime); |
|
109 } |
|
110 |
|
111 TInt CMMAAnimationFramePositioningControl::FindFrame(MIHLImageViewer* aViewer, TInt aFrameNumber) |
|
112 { |
|
113 TInt frame = 0; |
|
114 TInt count = aViewer->AnimationFrameCount(); |
|
115 if (aFrameNumber >= count) |
|
116 { |
|
117 frame = count - 1; |
|
118 } |
|
119 else if (aFrameNumber > 0) |
|
120 { |
|
121 frame = aFrameNumber; |
|
122 } |
|
123 return frame; |
|
124 } |
|
125 |
|
126 // END OF FILE |