20 #include "stsplayer.h" |
20 #include "stsplayer.h" |
21 #include <AudioPreference.h> |
21 #include <AudioPreference.h> |
22 #include <systemtoneservice.h> |
22 #include <systemtoneservice.h> |
23 #include "stsplayersettings.h" |
23 #include "stsplayersettings.h" |
24 #include "stssettingsmanager.h" |
24 #include "stssettingsmanager.h" |
|
25 #include "stsdebug.h" |
25 |
26 |
26 /*static*/CStsPlayer* CStsPlayer::Create(MStsPlayerObserver& aObserver, |
27 /*static*/CStsPlayer* CStsPlayer::Create(MStsPlayerObserver& aObserver, |
27 CStsSettingsManager& aSettingsManager, unsigned int aContext, |
28 CStsSettingsManager& aSettingsManager, unsigned int aContext, |
28 CSystemToneService::TAlarmType aAlarm) |
29 CSystemToneService::TAlarmType aAlarm) |
29 { |
30 { |
83 } |
84 } |
84 |
85 |
85 bool CStsPlayer::Init() |
86 bool CStsPlayer::Init() |
86 { |
87 { |
87 TRAPD(result, iPlayer = CMdaAudioPlayerUtility::NewL(*this)); |
88 TRAPD(result, iPlayer = CMdaAudioPlayerUtility::NewL(*this)); |
|
89 TRACE_LOG((_L("CStsPlayer::Init() : CMdaAudioPlayerUtility::NewL result[%d]"), result)); |
88 return result == KErrNone; |
90 return result == KErrNone; |
89 } |
91 } |
90 |
92 |
91 CStsPlayer::~CStsPlayer() |
93 CStsPlayer::~CStsPlayer() |
92 { |
94 { |
|
95 TRACE_FUNCTION_ENTRY; |
93 delete iPlayer; |
96 delete iPlayer; |
|
97 TRACE_FUNCTION_EXIT; |
94 } |
98 } |
95 |
99 |
96 void CStsPlayer::Play() |
100 void CStsPlayer::Play() |
97 { |
101 { |
98 // Play the tone |
102 // Play the tone |
99 TRAPD( err, iPlayer->OpenFileL(iPlayerSettings.GetFileName()) ); |
103 TRAPD( err, iPlayer->OpenFileL(iPlayerSettings.GetFileName()) ); |
|
104 TRACE_LOG((_L("CStsPlayer::Play() : CMdaAudioPlayerUtility::OpenFileL result[%d]"), err)); |
100 // If there is an error, indicate that the playback is complete. |
105 // If there is an error, indicate that the playback is complete. |
101 if (err) |
106 if (err) |
102 { |
107 { |
103 //TODO: Add trace here |
108 //TODO: Add trace here |
104 iObserver.PlayComplete(iContext); |
109 iObserver.PlayComplete(iContext); |
105 } |
110 } |
106 } |
111 } |
107 |
112 |
108 void CStsPlayer::Stop() |
113 void CStsPlayer::Stop() |
109 { |
114 { |
|
115 TRACE_FUNCTION_ENTRY; |
110 iPlayer->Stop(); |
116 iPlayer->Stop(); |
|
117 TRACE_FUNCTION_EXIT; |
111 } |
118 } |
112 |
119 |
113 void CStsPlayer::MapcInitComplete(TInt aError, |
120 void CStsPlayer::MapcInitComplete(TInt aError, |
114 const TTimeIntervalMicroSeconds& /*aDuration*/) |
121 const TTimeIntervalMicroSeconds& /*aDuration*/) |
115 { |
122 { |
122 iPlayer->SetPriority(iAudioPriority, iAudioPreference); |
129 iPlayer->SetPriority(iAudioPriority, iAudioPreference); |
123 iPlayer->SetRepeats(iPlayerSettings.GetNumberOfRepeats(), |
130 iPlayer->SetRepeats(iPlayerSettings.GetNumberOfRepeats(), |
124 iPlayerSettings.GetRepeatDelay()); |
131 iPlayerSettings.GetRepeatDelay()); |
125 iPlayer->SetVolume(volume); |
132 iPlayer->SetVolume(volume); |
126 iPlayer->SetVolumeRamp(iPlayerSettings.GetVolumeRamp()); |
133 iPlayer->SetVolumeRamp(iPlayerSettings.GetVolumeRamp()); |
|
134 TRACE_LOG((_L("CStsPlayer::Play() Settings-Priority[%d]Preference[0x%x]Repeats[%d]Volume[%d]"), |
|
135 iAudioPriority, |
|
136 iAudioPreference, |
|
137 iPlayerSettings.GetNumberOfRepeats(), |
|
138 volume)); |
|
139 TRACE_LOG((_L("CStsPlayer::Play() Settings-RepeatDelay[%d]VolumeRamp[0x%x]"), |
|
140 iPlayerSettings.GetRepeatDelay().Int64(), |
|
141 iPlayerSettings.GetVolumeRamp().Int64())); |
127 iPlayer->Play(); |
142 iPlayer->Play(); |
128 } |
143 } |
129 else |
144 else |
130 { |
145 { |
131 //TODO: add trace |
146 //TODO: add trace |
132 // Since there is an error, indicate that the playback is complete |
147 // Since there is an error, indicate that the playback is complete |
133 RDebug::Print(_L("InitCompleteReturned"), aError); |
148 //RDebug::Print(_L("InitCompleteReturned"), aError); |
|
149 TRACE_LOG((_L("CStsPlayer::MapcInitComplete() Error[%d]"), aError)); |
134 iObserver.PlayComplete(iContext); |
150 iObserver.PlayComplete(iContext); |
135 } |
151 } |
136 } |
152 } |
137 |
153 |
138 void CStsPlayer::MapcPlayComplete(TInt aError) |
154 void CStsPlayer::MapcPlayComplete(TInt aError) |
139 { |
155 { |
|
156 TRACE_LOG((_L("CStsPlayer::MapcPlayComplete() Error[%d]"), aError)); |
140 if (aError != KErrNone) |
157 if (aError != KErrNone) |
141 { |
158 { |
142 //TODO: add trace |
159 //TODO: add trace |
143 } |
160 } |
144 iObserver.PlayComplete(iContext); |
161 iObserver.PlayComplete(iContext); |