2007-10-03 22:26:39 +00:00
|
|
|
//
|
|
|
|
// MediaKeysApplication.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 10/3/07.
|
|
|
|
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MediaKeysApplication.h"
|
|
|
|
#import "AppController.h"
|
2013-10-12 21:26:52 +00:00
|
|
|
#import "Logging.h"
|
2007-10-03 22:26:39 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <MediaPlayer/MPMediaItem.h>
|
2019-11-14 03:13:59 +00:00
|
|
|
#import <MediaPlayer/MPNowPlayingInfoCenter.h>
|
|
|
|
#import <MediaPlayer/MPRemoteCommand.h>
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <MediaPlayer/MPRemoteCommandCenter.h>
|
2019-11-14 03:13:59 +00:00
|
|
|
#import <MediaPlayer/MPRemoteCommandEvent.h>
|
|
|
|
|
2022-06-10 01:58:42 +00:00
|
|
|
#import <Bugsnag/Bugsnag.h>
|
|
|
|
|
2021-02-06 21:33:47 +00:00
|
|
|
@implementation MediaKeysApplication {
|
2022-02-07 05:49:27 +00:00
|
|
|
AppController *_appController;
|
2021-02-06 21:33:47 +00:00
|
|
|
}
|
2007-10-03 22:26:39 +00:00
|
|
|
|
2022-06-10 01:58:42 +00:00
|
|
|
- (void)reportException:(NSException *)theException {
|
|
|
|
[Bugsnag notify:theException];
|
|
|
|
[super reportException:theException];
|
|
|
|
}
|
|
|
|
|
2013-10-12 21:26:52 +00:00
|
|
|
- (void)finishLaunching {
|
2022-02-07 05:49:27 +00:00
|
|
|
[super finishLaunching];
|
|
|
|
_appController = (AppController *)[self delegate];
|
2021-02-06 21:24:45 +00:00
|
|
|
|
2022-06-10 01:58:42 +00:00
|
|
|
[Bugsnag start];
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
|
2021-02-06 21:24:45 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[remoteCommandCenter.playCommand setEnabled:YES];
|
|
|
|
[remoteCommandCenter.pauseCommand setEnabled:YES];
|
|
|
|
[remoteCommandCenter.togglePlayPauseCommand setEnabled:YES];
|
|
|
|
[remoteCommandCenter.stopCommand setEnabled:YES];
|
|
|
|
[remoteCommandCenter.changePlaybackPositionCommand setEnabled:YES];
|
|
|
|
[remoteCommandCenter.nextTrackCommand setEnabled:YES];
|
|
|
|
[remoteCommandCenter.previousTrackCommand setEnabled:YES];
|
2021-02-06 21:24:45 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[[remoteCommandCenter playCommand] addTarget:self action:@selector(clickPlay)];
|
|
|
|
[[remoteCommandCenter pauseCommand] addTarget:self action:@selector(clickPause)];
|
|
|
|
[[remoteCommandCenter togglePlayPauseCommand] addTarget:self action:@selector(clickPlay)];
|
|
|
|
[[remoteCommandCenter stopCommand] addTarget:self action:@selector(clickStop)];
|
|
|
|
[[remoteCommandCenter changePlaybackPositionCommand] addTarget:self action:@selector(clickSeek:)];
|
|
|
|
[[remoteCommandCenter nextTrackCommand] addTarget:self action:@selector(clickNext)];
|
|
|
|
[[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)];
|
2019-11-14 03:13:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-15 03:24:13 +00:00
|
|
|
- (MPRemoteCommandHandlerStatus)clickPlay {
|
2022-02-07 05:49:27 +00:00
|
|
|
[_appController clickPlay];
|
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2019-11-15 03:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickPause {
|
2022-02-07 05:49:27 +00:00
|
|
|
[_appController clickPause];
|
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2019-11-15 03:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickStop {
|
2022-02-07 05:49:27 +00:00
|
|
|
[_appController clickStop];
|
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2019-11-15 03:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickNext {
|
2022-02-07 05:49:27 +00:00
|
|
|
[_appController clickNext];
|
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2019-11-15 03:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickPrev {
|
2022-02-07 05:49:27 +00:00
|
|
|
[_appController clickPrev];
|
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2019-11-15 03:24:13 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (MPRemoteCommandHandlerStatus)clickSeek:(MPChangePlaybackPositionCommandEvent *)event {
|
|
|
|
[_appController clickSeek:event.positionTime];
|
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2007-10-03 22:26:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|