简体   繁体   English

具有AVPlayer的选项卡栏可从TableView获取信息吗?

[英]Tab Bar with AVPlayer that gets info from tableview?

I have a AVPlayer that playes audio. 我有一个播放音频的AVPlayer。 What i need is, to have a TableView or something like it, with some names like: Tom Jones, and if that one is selected in the tableview, it passes a string to my AVPlayer, so the AVPlayer changes song. 我需要的是拥有一个TableView或类似名称的东西,名称如下:Tom Jones,如果在tableview中选择了那个名称,它将一个字符串传递给我的AVPlayer,因此AVPlayer会更改歌曲。

many ways to skin this cat. 这只猫有很多种皮毛。

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.player = [AVPlayer playerWithURL:[NSURL URLWithString:[[myArray objectAtIndex:indexPath.row] objectForKey:@"audio_url"]]];
}

*syntax not verified *语法未验证
this will only work of course if you have defined 'self.player' and 'myArray' 当然,只有在定义了'self.player'和'myArray'之后,这才起作用
self.player being your AVPlayer and myArray being an array of dictionaries, probably the same one that you would use in your UITableView DataSource self.player是您的AVPlayer,而myArray是一个字典数组,可能与您在UITableView DataSource中使用的字典相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM