【问题标题】:Pause AVPlayer in UITableView在 UITableView 中暂停 AVPlayer
【发布时间】:2014-05-15 16:49:38
【问题描述】:

我有一个 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];
    selectedRow = indexPath.row;
    [tableView reloadData];
    player = [AVPlayer playerWithURL:streamingURL];
    [player play];
    player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
} 

【问题讨论】:

    标签: ios objective-c uitableview avplayer


    【解决方案1】:

    您可以检查所选的indexPath.row 是否等于您的selectedRow
    如果是那么做[player pause];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-19
      • 2019-10-18
      • 2011-11-12
      • 2011-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多