//获取本地所有文件名称数组
NSFileManager * fileManager = [NSFileManager defaultManager];
NSArray * tempFileList = [[NSArray alloc] initWithArray:[fileManager contentsOfDirectoryAtPath:FILEPATH error:nil]];
//获取播放的本地URL
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
path = [path stringByAppendingFormat:@"/%@%@",_currentMusic.title,@".mp3"];
NSString *LocolMusic = [NSString stringWithFormat:@"%@%@",_currentMusic.title,@".mp3"];
if (![tempFileList containsObject:LocolMusic]) {
TimerDisappearAlertView *timer = [[TimerDisappearAlertView alloc] initWithTitle:@"本地文件损坏"];
[timer show];
[sender setTitle:@"Play" forState:UIControlStateNormal];
return;
}
//大按钮点进来
if (_index == -1) {
if (self.array == nil) {
[sender setTitle:@"Play" forState:UIControlStateNormal];
TimerDisappearAlertView *timer =[[TimerDisappearAlertView alloc] initWithTitle:@"快去选歌曲吧"];
[timer show];
}
else
{
if ([playerHelper shareHelper].isPlaying == YES) {
[[playerHelper shareHelper] stop];
self.imgView.transform = CGAffineTransformMakeRotation(0);
UIImage *image = [UIImage imageNamed:@"linkedin_128px_1069741_easyicon.net"];
sender.imageView.image = image;
[sender setTitle:@"Play" forState:UIControlStateNormal];
}
else
{
[[playerHelper shareHelper] play];
UIImage *image = [UIImage imageNamed:@"music_57.72972972973px_1160820_easyicon.net"];
sender.imageView.image = image;
[sender setTitle:@"Pause" forState:UIControlStateNormal];
TimerDisappearAlertView *timer =[[TimerDisappearAlertView alloc] initWithTitle:@"暂停下载"];
[timer show];
}
}
return;
}
//普通播放
if ([playerHelper shareHelper].isPlaying == YES) {
[[playerHelper shareHelper] stop];
self.imgView.transform = CGAffineTransformMakeRotation(0);
UIImage *image = [UIImage imageNamed:@"linkedin_128px_1069741_easyicon.net"];
sender.imageView.image = image;
[sender setTitle:@"Play" forState:UIControlStateNormal];
}
else{
[[playerHelper shareHelper] play];
UIImage *image = [UIImage imageNamed:@"music_57.72972972973px_1160820_easyicon.net"];
sender.imageView.image = image;
[sender setTitle:@"Pause" forState:UIControlStateNormal];
}