私はサウンド クラウド SDK を使用しています。そのライブラリを使用してオーディオ ストリームを再生しようとしています。
そのクラスの使用方法に関するリファレンスを見つけることができませんでした。
ご協力いただければ幸いです。
私はサウンド クラウド SDK を使用しています。そのライブラリを使用してオーディオ ストリームを再生しようとしています。
そのクラスの使用方法に関するリファレンスを見つけることができませんでした。
ご協力いただければ幸いです。
このライブラリについて話している場合は、私がお手伝いします。
まず、このメソッドを実行して、トラックに関する情報を ID で取得する必要があります。
[api performMethod: @"GET"
onResource: @"tracks"
withParameters: [NSDictionary dictionaryWithObject:trackID forKey:@"ids"]
context: @"trackid"
userInfo: nil];
trackID がわからず、次のようなトラックへのリンクしかない場合: http://soundcloud.com/go-yoshimura/mikasasukasa、次のメソッドを実行します。
[api performMethod: @"GET"
onResource: @"resolve"
withParameters: [NSDictionary dictionaryWithObject:songLink forKey:@"url"]
context: @"songname"
userInfo: nil];
次に、デリゲートのメソッドを実装する必要があります。
- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI
didFinishWithData:(NSData *)data
context:(id)context
userInfo:(id)userInfo;
- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI
didFailWithError:(NSError *)error
context:(id)context
userInfo:(id)userInfo;
最初の方法では、JSON パーサー (JSONKit または SBJSON) を使用してデータを解析する必要があります。NSDictionary を取得する必要があります。
streamURL = [(NSDictionary *)jsonData objectForKey:@"stream_url"];
streamable = [[(NSDictionary *)jsonData objectForKey:@"streamable"] boolValue];
このトラックがストリーミング可能な場合、次の方法で SCAudioStream を取得できます。
stream = [[SCAudioStream alloc] initWithURL:[NSURL URLWithString:streamURL] authentication:auth];
この方法で init メソッドで以前に作成できる Auth:
conf = [SCSoundCloudAPIConfiguration configurationForProductionWithClientID: kSCClientID
clientSecret: kSCClientSecret
redirectURL: kSCRedirectURL];
auth = [[SCSoundCloudAPIAuthentication alloc] initWithAuthenticationDelegate:self apiConfiguration:conf];
これで、SCAudioStream ができました。
//Playing
[stream play];
//Pause
[srteam pause];
//Seeking
[stream seekToMillisecond:ms startPlaying:YES];
それで全部です :)