32 |
32 |
33 //----------------------------------------------------------------------------- |
33 //----------------------------------------------------------------------------- |
34 // Constructor / destructor |
34 // Constructor / destructor |
35 //----------------------------------------------------------------------------- |
35 //----------------------------------------------------------------------------- |
36 |
36 |
37 MMF::AudioPlayer::AudioPlayer() |
37 MMF::AudioPlayer::AudioPlayer(MediaObject *parent, const AbstractPlayer *player) |
38 { |
38 : AbstractMediaPlayer(parent, player) |
39 construct(); |
39 , m_totalTime(0) |
40 } |
|
41 |
|
42 MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) |
|
43 : AbstractMediaPlayer(player) |
|
44 { |
40 { |
45 construct(); |
41 construct(); |
46 } |
42 } |
47 |
43 |
48 void MMF::AudioPlayer::construct() |
44 void MMF::AudioPlayer::construct() |
49 { |
45 { |
50 TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); |
46 TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); |
51 TRACE_ENTRY_0(); |
47 TRACE_ENTRY_0(); |
52 |
48 |
53 TRAPD(err, m_player.reset(CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone))); |
49 NativePlayer *player = 0; |
54 if (KErrNone != err) { |
50 QT_TRAP_THROWING(player = NativePlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); |
55 changeState(ErrorState); |
51 m_player.reset(player); |
56 } |
52 m_player->RegisterForAudioLoadingNotification(*this); |
57 |
53 |
58 TRACE_EXIT_0(); |
54 TRACE_EXIT_0(); |
59 } |
55 } |
60 |
56 |
61 MMF::AudioPlayer::~AudioPlayer() |
57 MMF::AudioPlayer::~AudioPlayer() |
62 { |
58 { |
63 TRACE_CONTEXT(AudioPlayer::~AudioPlayer, EAudioApi); |
59 TRACE_CONTEXT(AudioPlayer::~AudioPlayer, EAudioApi); |
64 TRACE_ENTRY_0(); |
60 TRACE_ENTRY_0(); |
65 |
61 |
66 TRACE_EXIT_0(); |
62 TRACE_EXIT_0(); |
|
63 } |
|
64 |
|
65 MMF::AudioPlayer::NativePlayer *MMF::AudioPlayer::nativePlayer() const |
|
66 { |
|
67 return m_player.data(); |
67 } |
68 } |
68 |
69 |
69 //----------------------------------------------------------------------------- |
70 //----------------------------------------------------------------------------- |
70 // Public API |
71 // Public API |
71 //----------------------------------------------------------------------------- |
72 //----------------------------------------------------------------------------- |
149 } else { |
168 } else { |
150 TRACE("GetPosition err %d", err); |
169 TRACE("GetPosition err %d", err); |
151 |
170 |
152 // If we don't cast away constness here, we simply have to ignore |
171 // If we don't cast away constness here, we simply have to ignore |
153 // the error. |
172 // the error. |
154 const_cast<AudioPlayer*>(this)->setError(NormalError); |
173 const_cast<AudioPlayer*>(this)->setError(tr("Getting position failed"), err); |
155 } |
174 } |
156 |
175 |
157 return result; |
176 return result; |
158 } |
177 } |
159 |
178 |
160 qint64 MMF::AudioPlayer::totalTime() const |
179 qint64 MMF::AudioPlayer::totalTime() const |
161 { |
180 { |
162 return toMilliSeconds(m_player->Duration()); |
181 return m_totalTime; |
163 } |
182 } |
164 |
183 |
165 |
184 |
166 //----------------------------------------------------------------------------- |
185 //----------------------------------------------------------------------------- |
167 // Symbian multimedia client observer callbacks |
186 // Symbian multimedia client observer callbacks |
180 |
199 |
181 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); |
200 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); |
182 |
201 |
183 if (KErrNone == aError) { |
202 if (KErrNone == aError) { |
184 maxVolumeChanged(m_player->MaxVolume()); |
203 maxVolumeChanged(m_player->MaxVolume()); |
185 emit totalTimeChanged(totalTime()); |
204 m_totalTime = toMilliSeconds(m_player->Duration()); |
|
205 emit totalTimeChanged(m_totalTime); |
186 updateMetaData(); |
206 updateMetaData(); |
187 changeState(StoppedState); |
207 changeState(StoppedState); |
188 } else { |
208 } else { |
189 // TODO: set different error states according to value of aError? |
209 setError(tr("Opening clip failed"), aError); |
190 setError(NormalError); |
|
191 } |
210 } |
192 |
211 |
193 TRACE_EXIT_0(); |
212 TRACE_EXIT_0(); |
194 } |
213 } |
195 |
214 |
200 #endif |
219 #endif |
201 { |
220 { |
202 TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); |
221 TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); |
203 TRACE_ENTRY("state %d error %d", state(), aError); |
222 TRACE_ENTRY("state %d error %d", state(), aError); |
204 |
223 |
205 stopTickTimer(); |
224 // Call base class function which handles end of playback for both |
206 |
225 // audio and video clips. |
207 if (KErrNone == aError) { |
226 playbackComplete(aError); |
208 changeState(StoppedState); |
227 |
209 // TODO: move on to m_nextSource |
228 TRACE_EXIT_0(); |
210 } else { |
229 } |
211 // TODO: do something with aError? |
|
212 setError(NormalError); |
|
213 } |
|
214 |
|
215 /* |
|
216 if (aError == KErrNone) { |
|
217 if (m_nextSource.type() == MediaSource::Empty) { |
|
218 emit finished(); |
|
219 } else { |
|
220 setSource(m_nextSource); |
|
221 m_nextSource = MediaSource(); |
|
222 } |
|
223 |
|
224 changeState(StoppedState); |
|
225 } |
|
226 else { |
|
227 m_error = NormalError; |
|
228 changeState(ErrorState); |
|
229 } |
|
230 */ |
|
231 |
|
232 TRACE_EXIT_0(); |
|
233 } |
|
234 |
|
235 CPlayerType *MMF::AudioPlayer::player() const |
|
236 { |
|
237 return m_player.data(); |
|
238 } |
|
239 |
|
240 |
230 |
241 #ifdef QT_PHONON_MMF_AUDIO_DRM |
231 #ifdef QT_PHONON_MMF_AUDIO_DRM |
242 void MMF::AudioPlayer::MaloLoadingStarted() |
232 void MMF::AudioPlayer::MaloLoadingStarted() |
243 { |
233 { |
244 |
234 |
247 void MMF::AudioPlayer::MaloLoadingComplete() |
237 void MMF::AudioPlayer::MaloLoadingComplete() |
248 { |
238 { |
249 |
239 |
250 } |
240 } |
251 #endif // QT_PHONON_MMF_AUDIO_DRM |
241 #endif // QT_PHONON_MMF_AUDIO_DRM |
|
242 |
|
243 |
|
244 //----------------------------------------------------------------------------- |
|
245 // MAudioLoadingObserver callbacks |
|
246 //----------------------------------------------------------------------------- |
|
247 |
|
248 void MMF::AudioPlayer::MaloLoadingStarted() |
|
249 { |
|
250 bufferingStarted(); |
|
251 } |
|
252 |
|
253 void MMF::AudioPlayer::MaloLoadingComplete() |
|
254 { |
|
255 bufferingComplete(); |
|
256 } |
252 |
257 |
253 |
258 |
254 //----------------------------------------------------------------------------- |
259 //----------------------------------------------------------------------------- |
255 // Private functions |
260 // Private functions |
256 //----------------------------------------------------------------------------- |
261 //----------------------------------------------------------------------------- |