-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.x
35 lines (30 loc) · 1.16 KB
/
Tweak.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <AVFoundation/AVFoundation.h>
#include <AppSupport/CPDistributedMessagingCenter.h>
%hook SpringBoard
AVAudioPlayer *player;
- (void)applicationDidFinishLaunching:(id)application {
%orig;
player = [AVAudioPlayer new];
CPDistributedMessagingCenter *center = [CPDistributedMessagingCenter centerNamed:@"com.artikus.playcenter"];
[center runServerOnCurrentThread];
[center registerForMessageName:@"playAudio" target:self selector:@selector(play:message:)];
}
%new
- (NSDictionary *)play:(NSString *)name message:(NSDictionary *)userInfo {
if([[userInfo objectForKey:@"message"] isEqualToString:@"stop"]) {
printf("Stopping audio playback.");
[player stop];
} else if([[userInfo objectForKey:@"message"] isEqualToString:@"pause"]) {
printf("Pausing audio playback.");
[player pause];
} else if([[userInfo objectForKey:@"message"] isEqualToString:@"play"]) {
printf("Starting playback again.");
[player play];
} else {
player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[userInfo objectForKey:@"message"] isDirectory:NO] error:nil];
[player prepareToPlay];
[player play];
}
return nil;
}
%end