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
|
|
|
|
2019-11-14 03:13:59 +00:00
|
|
|
#import <MediaPlayer/MPNowPlayingInfoCenter.h>
|
|
|
|
#import <MediaPlayer/MPRemoteCommandCenter.h>
|
|
|
|
#import <MediaPlayer/MPRemoteCommand.h>
|
|
|
|
#import <MediaPlayer/MPMediaItem.h>
|
|
|
|
#import <MediaPlayer/MPRemoteCommandEvent.h>
|
|
|
|
|
2021-02-06 21:33:47 +00:00
|
|
|
@implementation MediaKeysApplication {
|
|
|
|
AppController *_appController;
|
|
|
|
}
|
2007-10-03 22:26:39 +00:00
|
|
|
|
2013-10-12 21:26:52 +00:00
|
|
|
- (void)finishLaunching {
|
|
|
|
[super finishLaunching];
|
2021-02-06 21:33:47 +00:00
|
|
|
_appController = (AppController *)[self delegate];
|
2021-02-06 21:24:45 +00:00
|
|
|
|
|
|
|
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
|
|
|
|
|
|
|
|
[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];
|
|
|
|
|
|
|
|
[[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 {
|
2021-02-06 21:33:47 +00:00
|
|
|
[_appController clickPlay];
|
2019-11-15 03:24:13 +00:00
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickPause {
|
2021-02-06 21:33:47 +00:00
|
|
|
[_appController clickPause];
|
2019-11-15 03:24:13 +00:00
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickStop {
|
2021-02-06 21:33:47 +00:00
|
|
|
[_appController clickStop];
|
2019-11-15 03:24:13 +00:00
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickNext {
|
2021-02-06 21:33:47 +00:00
|
|
|
[_appController clickNext];
|
2019-11-15 03:24:13 +00:00
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickPrev {
|
2021-02-06 21:33:47 +00:00
|
|
|
[_appController clickPrev];
|
2019-11-15 03:24:13 +00:00
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MPRemoteCommandHandlerStatus)clickSeek: (MPChangePlaybackPositionCommandEvent*)event {
|
2021-02-06 21:33:47 +00:00
|
|
|
[_appController clickSeek:event.positionTime];
|
2019-11-15 03:24:13 +00:00
|
|
|
return MPRemoteCommandHandlerStatusSuccess;
|
2007-10-03 22:26:39 +00:00
|
|
|
}
|
|
|
|
|
2013-10-12 21:41:57 +00:00
|
|
|
|
2007-10-03 22:26:39 +00:00
|
|
|
@end
|