带有 AVPlayer 的选项卡栏从 tableview 获取信息?

发布于 2024-10-20 21:27:30 字数 136 浏览 5 评论 0原文

我有一个播放音频的 AVPlayer。 我需要的是,有一个 TableView 或类似的东西,带有一些名称,例如:Tom Jones,如果在 tableview 中选择了该名称,它将向我的 AVPlayer 传递一个字符串,以便 AVPlayer 更改歌曲。

I have a AVPlayer that playes audio.
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月蹉跎了容颜 2024-10-27 21:27:30

有很多方法可以给这只猫剥皮。

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

*语法未验证
当然,只有当您定义了“self.player”和“myArray”时,这才有效
self.player 是您的 AVPlayer,myArray 是一组字典,可能与您在 UITableView 数据源中使用的字典数组相同

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 being your AVPlayer and myArray being an array of dictionaries, probably the same one that you would use in your UITableView DataSource

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文