导入MP3文件

2. 再导入#import <AVFoundation/AVFoundation.h>
//1.  添加属性:@property(nonatomic,strong)AVPlayer *player;
// 2. 将MP3文件拽到当前工程,用bundle扫描当前工程的文件找到MP3文件
- (void)viewDidLoad {
    [super viewDidLoad];
    //播放本地音乐
    //获取音乐文件的路径
    NSString *path = [[NSBundle mainBundle]pathForResource:@"frxz" ofType:@"mp3"];
    NSURL *url = [NSURL fileURLWithPath:path];
    self.player = [AVPlayer playerWithURL:url];  //+1
    [self.player play];

 //创建 音乐播放类
//    AVPlayer *play = [AVPlayer  playerWithURL:url]; //网上下载的文件
//    [play play];
成功的三大原则: 1、坚持 2、不要脸 3、坚持不要脸
原文地址:https://www.cnblogs.com/xulinmei/p/7442700.html