【发布时间】:2014-05-15 11:24:12
【问题描述】:
我正在尝试使用 AVPlayer 播放来自 URL 的音频,当在表格视图中选择了一行但它没有播放时。我做错了什么?
代码如下:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *streamingString = [NSString stringWithFormat:@"%@.json?client_id=fc886d005e29ba78f046e5474e3fdefb", [streamURLArray objectAtIndex:indexPath.row]];
NSURL *streamingURL = [NSURL URLWithString:streamingString];
NSLog(@"%@", streamingURL);
AVPlayer *player = [AVPlayer playerWithURL:streamingURL];
[player play];
player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
}
当我记录它时,streamingURL 的一个例子是这样的。
http://api.soundcloud.com/tracks/146814101/stream.json?client_id=fc886d005e29ba78f046e5474e3fdefb
【问题讨论】:
标签: ios objective-c avplayer