When I tap on an image view, I am trying to play music. When I run the following code, the music doesn't play. The music is an .m4a:
.h
#import <AVFoundation/AVFoundation.h>
@interface ChooseViewController : UIViewController {
AVAudioPlayer *audioPlayer;
}
@property (strong, nonatomic) AVAudioPlayer *audioPlayer;
.m
- (void)imageTaped:(UIGestureRecognizer *)gestureRecognizer {
//
self.songURL = [NSURL URLWithString:@"http://a1745.phobos.apple.com/us/r1000/011/Music6/v4/91/d0/45/91d0451d-c2cd-911a-491e-4f51c02e6b38/mzaf_4642375274280516284.plus.aac.p.m4a"];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:self.songURL
error:nil];
[audioPlayer play];
}