4
我想使用Soundcloud API在我的應用程序中播放公共聲音。在網絡搜索後,我找到了一種方法來做到這一點,但我無法讓我的代碼工作。下面是我試圖播放聲音的代碼:Soundcloud iOS API - 播放鏈接中的聲音
NSString *publicTrackUrlString = @"https://soundcloud.com/miroslav-osipovic/the-cat-empire-the-lost-song";
NSString *urlString = [NSString stringWithFormat:@"%@?client_id=64a52bb31abd2ec73f8adda86358cfbf", publicTrackUrlString];
[SCRequest performMethod:SCRequestMethodGET
onResource:[NSURL URLWithString:urlString]
usingParameters:nil
withAccount:nil
sendingProgressHandler:nil
responseHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSError *playerError;
player = [[AVAudioPlayer alloc] initWithData:data error:&playerError];
[player prepareToPlay];
[player play];
}];
謝謝你,真的很有幫助。 –