forked from abart997/PlayingLyrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.xm
63 lines (41 loc) · 1.76 KB
/
Tweak.xm
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#import <UIKit/UIKit.h>
#import <UIKit/UIKit2.h>
#import <MediaPlayer/MediaPlayer.h>
#import <MediaPlayer/MPMusicPlayerController.h>
#import <MediaPlayer/MPMediaItem.h>
#import <libactivator/libactivator.h>
#import <notify.h>
static UIAlertView *alert;
@interface PlayingLyrics : NSObject<LAListener, UIAlertViewDelegate> {
}
@end
@implementation PlayingLyrics
- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event{
alert = [[UIAlertView alloc]initWithTitle:@"PlayingLyrics" message:@"Do you want to show the lyrics of your playing song?" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Yes",nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alert didDismissWithButtonIndex:(NSInteger)buttonIndex{
if(buttonIndex == 1){
MPMusicPlayerController *musicPlayer;
musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
MPMediaItem *currentItem = [musicPlayer nowPlayingItem];
NSString *textLyrics = [currentItem valueForProperty:@"lyrics"];
UIAlertView *alertLyrics = [[UIAlertView alloc]initWithTitle:@"Song lyrics" message:[NSString stringWithFormat:@"%@", textLyrics] delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
[alertLyrics show];
[alertLyrics release];
if (textLyrics == nil){
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"No lyrics" message:@"No lyrics founded in this song" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
}
+ (void)load
{
if (![[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]) {return;}
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
[[LAActivator sharedInstance] registerListener:[self new] forName:@"com.abart997.playinglyrics"];
[p release];
}
@end