#import <AVFoundation/AVFoundation.h>
//创建播放器
NSUrl *url = [[NSBundle mainBundle] URLForResource:@"mySong1.mp3", withExtension:nil];
AVPlayerItem *playerItem= [[AVPlayerItem alloc] initWithUrl:url];
self.player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
[self.player play]; //播放
[self.player pause]; //暂停
[self.player replaceCurrentItemWithPlayerItem:musicItem]; //切换歌曲
iOS中播放音效
最新推荐文章于 2023-12-31 22:29:07 发布