Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry0523 committed Oct 21, 2015
1 parent 04d4eaf commit 0af5037
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions EasyPlayer/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification {

- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
NSMenuItem *pre = [[NSMenuItem alloc] initWithTitle:@"上一首" action:@selector(playPreSong) keyEquivalent:@""];
NSMenuItem *play = [[NSMenuItem alloc] initWithTitle:self.playerController.isPlaying ? @"暂停" : @"播放" action:@selector(resumePlaySong) keyEquivalent:@""];
NSMenuItem *next = [[NSMenuItem alloc] initWithTitle:@"下一首" action:@selector(playNextSong) keyEquivalent:@""];
NSMenuItem *pre = [[NSMenuItem alloc] initWithTitle:@"Previous" action:@selector(playPreSong) keyEquivalent:@""];
NSMenuItem *play = [[NSMenuItem alloc] initWithTitle:self.playerController.isPlaying ? @"Pause" : @"Play" action:@selector(resumePlaySong) keyEquivalent:@""];
NSMenuItem *next = [[NSMenuItem alloc] initWithTitle:@"Next" action:@selector(playNextSong) keyEquivalent:@""];
[menu addItem:pre];
[menu addItem:play];
[menu addItem:next];
Expand Down
1 change: 1 addition & 0 deletions EasyPlayer/Extentions/MusicTools/JWMediaHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

+ (NSImage*)innerCoverImageForURL:(NSURL*)url;
+ (NSDictionary *)id3InfoForURL:(NSURL*)url;
+ (void)scanSupportedMediaForFileURL:(NSURL*)fileURL into:(NSMutableArray*)array;

+ (void)getLrcForTrack:(JWTrack*)track onComplete:(void (^)(NSString*, JWTrack *track, NSError *))block;
+ (void)getAlbumImageForTrack:(JWTrack*)track onComplete:(void (^)(NSImage*, JWTrack *track, NSError *))block;
Expand Down
19 changes: 19 additions & 0 deletions EasyPlayer/Extentions/MusicTools/JWMediaHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@

@implementation JWMediaHelper

+ (void)scanSupportedMediaForFileURL:(NSURL*)fileURL into:(NSMutableArray*)array {
NSDictionary *id3Dic = [self id3InfoForURL:fileURL];
if(id3Dic) {
JWTrack *track = [[JWTrack alloc] initFromID3Info:id3Dic url:fileURL];
track.sourceType = TrackSourceTypeLocal;

if (id3Dic[@"picture"]) {
NSImage *coverImg = [[NSImage alloc] initWithData:id3Dic[@"picture"]];
NSString *albumPath = [JWFileManager getCoverPath];
if (albumPath) {
NSString *destination = [albumPath stringByAppendingPathComponent:[track cacheKey]];
[coverImg saveAsJPGFileForPath:destination];
}

}
[array addObject:track];
}
}

+ (NSImage*)innerCoverImageForURL:(NSURL*)fileURL {
AudioFileID audioFile;
OSStatus theErr = noErr;
Expand Down
20 changes: 2 additions & 18 deletions EasyPlayer/PlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ - (IBAction)addButtonClicked:(NSButton *)sender {
sender.state = 1;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:YES];
[openDlg setCanChooseDirectories:NO];
[openDlg setAllowsMultipleSelection:YES];

NSArray *urlArray;
Expand All @@ -303,23 +303,7 @@ - (IBAction)addButtonClicked:(NSButton *)sender {
NSMutableArray *newTracks = [NSMutableArray array];

for (NSURL *url in urlArray) {
NSDictionary *id3Dic = [JWMediaHelper id3InfoForURL:url];
if(id3Dic) {
JWTrack *track = [[JWTrack alloc] initFromID3Info:id3Dic url:url];
track.sourceType = TrackSourceTypeLocal;

if (id3Dic[@"picture"]) {
NSImage *coverImg = [[NSImage alloc] initWithData:id3Dic[@"picture"]];
NSString *albumPath = [JWFileManager getCoverPath];
if (albumPath) {
NSString *destination = [albumPath stringByAppendingPathComponent:[track cacheKey]];
[coverImg saveAsJPGFileForPath:destination];
}

}

[newTracks addObject:track];
}
[JWMediaHelper scanSupportedMediaForFileURL:url into:newTracks];
}

NSMutableArray *mutable = [NSMutableArray arrayWithArray:self.items];
Expand Down

0 comments on commit 0af5037

Please sign in to comment.