このリンクを取得できないようです:
https://api.soundcloud.com/tracks/54507667/stream
AVAudioPlayerで動作します。Souncloud APIで開始したプロジェクトでテストしましたが、問題なく動作しているようですが、自分で実装しようとすると動作しないようです。
私が得るエラー:
認識されないセレクターがインスタンス0x9245d40に送信されました2013-01-0417:56:04.699 CollectionViewTest [17023:c07] *キャッチされない例外'NSInvalidArgumentException'によるアプリの終了、理由:'-[__ NSCFString AbsoluteURL]:認識されないセレクターがインスタンス0x9245d40に送信されました' *最初のスローコールスタック:....。
コード:
NSURL *streamURL = [NSString stringWithFormat:@"%@",
allDataDictionarySound[@"stream_url"], nil];
NSLog(streamURL);
NSURLRequest *request = [NSURLRequest requestWithURL:streamURL];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
connectionPlay = [[NSURLConnection alloc] initWithRequest:request delegate:self];
NSLog(@"test:");
NSError *playerError;
player = [[AVAudioPlayer alloc] initWithData:streamData error:&playerError];
NSLog(@"test:2");
streamURLが期待どおりに出力された後、プログラムがクラッシュします。
テストは印刷されません。他のすべてがコメント化され、NSURLRequestが残っている場合でも、クラッシュします。コードのブロック全体をコメントアウトすると、すべてがコンパイルされて実行されます。
私は今これを試みました:
NSData *_objectData = [NSData dataWithContentsOfURL:streamURL];
NSError *error;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:_objectData error:&error];
audioPlayer.numberOfLoops = 0;
audioPlayer.volume = 1.0f;
[audioPlayer prepareToPlay];
if (audioPlayer == nil)
NSLog(@"%@", [error description]);
else
[audioPlayer play];
これも長さのエラーを返します、私はこれを引き起こしている可能性があるものに途方に暮れています...
2013-01-05 13:46:16.536 CollectionViewTest[28224:c07] -[NSURL length]: unrecognized selector sent to instance 0x928a470
2013-01-05 13:46:16.546 CollectionViewTest [28224:c07] *キャッチされなかった例外'NSInvalidArgumentException'が原因でアプリを終了しています、理由:'-[NSURLの長さ]:認識されないセレクターがインスタンス0x928a470に送信されました' *最初のスロー呼び出しスタック: