I\'m trying to play an mp3 (camera shutter sound) using AVPlayer. I\'ve stripped everything down to a simple button that, when pressed, plays the sound. All of the objects a
Try these lines and replace "yoursound.mp3" with your file name.:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/yoursound.mp3", [[NSBundle mainBundle] resourcePath]]];
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset];
avplayer = [AVPlayer playerWithPlayerItem:anItem];
[avplayer play];
'player' is released the end of method. It must be reserved as a class variable.