31 #include "sbIMediacoreManager.h"
32 #include "sbIMediacoreStatus.h"
33 #include "sbIApplicationController.h"
44 - (
id)initWithCallback:(sbAppleRemoteService *)aCallback;
46 - (void)startListening;
47 - (void)stopListening;
54 - (
id)initWithCallback:(sbAppleRemoteService *)aCallback
56 if ((
self = [super
init])) {
66 [mAppleRemote release];
86 mOwner->OnVolumeUpPressed();
89 mOwner->OnVolumeDownPressed();
92 mOwner->OnMenuButtonPressed();
95 mOwner->OnPlayButtonPressed();
98 mOwner->OnNextTrackReleased();
101 mOwner->OnPrevTrackReleased();
122 sbAppleRemoteService::sbAppleRemoteService()
127 sbAppleRemoteService::~sbAppleRemoteService()
133 sbAppleRemoteService::StartListening()
135 [mDelegate startListening];
140 sbAppleRemoteService::StopListening()
142 [mDelegate stopListening];
147 sbAppleRemoteService::GetIsSupported(PRBool *aIsSupported)
149 NS_ENSURE_ARG_POINTER(aIsSupported);
155 sbAppleRemoteService::OnPlayButtonPressed()
158 nsCOMPtr<sbIMediacoreManager> manager =
159 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
160 NS_ENSURE_SUCCESS(rv, rv);
162 nsCOMPtr<sbIMediacorePlaybackControl> playbackControl;
163 rv = manager->GetPlaybackControl(getter_AddRefs(playbackControl));
165 PRBool isPlaying = PR_FALSE;
166 GetIsPlaybackPlaying(&isPlaying);
168 if (NS_SUCCEEDED(rv) && playbackControl && isPlaying) {
169 nsCOMPtr<sbIMediacoreStatus> status;
170 rv = manager->GetStatus(getter_AddRefs(status));
171 NS_ENSURE_SUCCESS(rv, rv);
174 rv = status->GetState(&state);
175 NS_ENSURE_SUCCESS(rv, NO);
180 rv = playbackControl->Pause();
181 NS_ENSURE_SUCCESS(rv, rv);
185 nsCOMPtr<sbIApplicationController> appController =
186 do_GetService(
"@songbirdnest.com/Songbird/ApplicationController;1", &rv);
187 NS_ENSURE_SUCCESS(rv, rv);
189 rv = appController->PlayDefault();
190 NS_ENSURE_SUCCESS(rv, rv);
197 sbAppleRemoteService::OnMenuButtonPressed()
200 return NS_ERROR_NOT_IMPLEMENTED;
204 sbAppleRemoteService::OnVolumeUpPressed()
207 nsCOMPtr<sbIMediacoreVolumeControl> volControl;
208 rv = GetVolumeControl(getter_AddRefs(volControl));
209 NS_ENSURE_SUCCESS(rv, rv);
212 rv = volControl->GetVolume(&curVolume);
213 NS_ENSURE_SUCCESS(rv, rv);
219 return volControl->SetVolume(curVolume);
223 sbAppleRemoteService::OnVolumeDownPressed()
226 nsCOMPtr<sbIMediacoreVolumeControl> volControl;
227 rv = GetVolumeControl(getter_AddRefs(volControl));
228 NS_ENSURE_SUCCESS(rv, rv);
231 rv = volControl->GetVolume(&curVolume);
232 NS_ENSURE_SUCCESS(rv, rv);
238 return volControl->SetVolume(curVolume);
242 sbAppleRemoteService::OnNextTrackPressed()
245 return NS_ERROR_NOT_IMPLEMENTED;
249 sbAppleRemoteService::OnNextTrackReleased()
252 nsCOMPtr<sbIMediacoreSequencer> sequencer;
253 rv = GetSequencer(getter_AddRefs(sequencer));
254 NS_ENSURE_SUCCESS(rv, rv);
256 return sequencer->Next(
false);
260 sbAppleRemoteService::OnPrevTrackPressed()
262 return NS_ERROR_NOT_IMPLEMENTED;
266 sbAppleRemoteService::OnPrevTrackReleased()
269 nsCOMPtr<sbIMediacoreSequencer> sequencer;
270 rv = GetSequencer(getter_AddRefs(sequencer));
271 NS_ENSURE_SUCCESS(rv, rv);
273 return sequencer->Previous(
false);
280 nsCOMPtr<sbIMediacoreManager> manager =
281 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
282 NS_ENSURE_SUCCESS(rv, rv);
284 return manager->GetPlaybackControl(aPlayCntrl);
291 nsCOMPtr<sbIMediacoreManager> manager =
292 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
293 NS_ENSURE_SUCCESS(rv, rv);
295 return manager->GetSequencer(aSequencer);
302 nsCOMPtr<sbIMediacoreManager> manager =
303 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
304 NS_ENSURE_SUCCESS(rv, rv);
306 return manager->GetVolumeControl(aVolControl);
310 sbAppleRemoteService::GetIsPlaybackPlaying(PRBool *aIsPlaying)
312 NS_ENSURE_ARG_POINTER(aIsPlaying);
315 nsCOMPtr<sbIMediacoreManager> manager =
316 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
317 NS_ENSURE_SUCCESS(rv, rv);
319 nsCOMPtr<sbIMediacoreStatus> status;
320 rv = manager->GetStatus(getter_AddRefs(status));
321 NS_ENSURE_SUCCESS(rv, rv);
324 rv = status->GetState(&state);
325 NS_ENSURE_SUCCESS(rv, rv);
SBAppleRemoteListener * mAppleRemote
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
sbAppleRemoteService * mOwner