iOS :播放音效,ios播放音效
投稿于 被查看 26232 次 评论:42
iOS :播放音效,ios播放音效
AVFoundation/AVFoundation.h 框架
// 创建播放器 // 取MP3文件路径 NSURL *url = [[NSBundle mainBundle] URLForResource:@"mySong1.mp3" withExtension:nil]; // 创建播放器 AVPlayer *player = [[AVPlayer alloc] init]; // 播放的音乐 AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:url]; // 传入播放器 player = [[AVPlayer alloc] initWithPlayerItem:playerItem]; // 播放 [player play];
用户评论