我正在使用GUIPLAYERVIDE示例代码: https://github.com/guilhermearaujo/GUIPlayerView
我创建了一个包含URL流链接的数组。
当我按第1行视频开始时。 当我按下第2行时,视频开始但前一个视频(第1行)的声音仍在播放。
如何选择另一行时停止流?
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat width = [UIScreen mainScreen].bounds.size.width;
playerView = [[GUIPlayerView alloc] initWithFrame:CGRectMake(0, 20, width, width * 9.0f / 16.0f)];
[playerView setDelegate:self];
[[self view] addSubview:playerView];
itemArray = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:@"1HD Music", @"stationName", @"dsgdfsgdfgdfs", @"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Rus Music Box", @"stationName", @"sdgdfgdsfgsfgd", @"url", nil],
nil];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"stationName" ascending:YES];
itemArray = [itemArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"selected tableview row is %ld",(long)indexPath.row);
NSLog(@"%@",itemArray);
NSDictionary *item = [itemArray objectAtIndex:indexPath.row];
NSURL * urlStream = [NSURL URLWithString:[item objectForKey:@"url"]];
[playerView setVideoURL:urlStream];
[playerView prepareAndPlayAutomatically:YES];
}