当用户选择集合视图自定义单元格时,我想播放 mp3 文件文件。但它不玩。这是我为此目的编写的代码 -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"cell selected ");
AVAudioPlayer * audioPlayer;
NSString *path = [[NSBundle mainBundle] pathForResource:@"bismillah" ofType:@"mp3"];
NSURL *audioUrl=[NSURL fileURLWithPath:path];
audioPlayer=[[AVAudioPlayer alloc] initWithContentsOfURL:audioUrl error:nil];
//audioPlayer.delegate=self;
[audioPlayer play];
// cell.backgroundColor = [UIColor blueColor];
}