-2
のmp3ファイルをダウンロードして再生するmp3ファイルをダウンロードしましたが、再生できません。ファイルがダウンロードされた、私はチェックしたが、ローカルファイルを再生しようとすると、何も起こりません。私はそれをダウンロードせずに直接再生すると再生されます。URLから
- (IBAction)downloadTrack:(id)sender {
NSData *soundData = [NSData dataWithContentsOfURL:self.song.ticket.url];
NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *filePath = [documents stringByAppendingPathComponent:self.song.slug];
[soundData writeToFile:filePath atomically:YES];
NSURL *urlFile = [NSURL URLWithString:filePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:urlFile error:nil];
player.numberOfLoops = -1; //Infinite
[player play];
}