-
(void)viewDidLoad {
[super viewDidLoad];
//找到包路径
NSString * path = [[NSBundle mainBundle] pathForResource:@“song1” ofType:@“mp3”];
//转为url
NSURL * url = [NSURL URLWithString:path];
//把url 添加到播放器里面来
_player = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];
//音量
_player.volume = 0.5;
//循环播放次数(默认1,若设置值大于0,则为相应的循环次数,设置为-1可以实现无限循环):
_player.numberOfLoops = -1;
[_player prepareToPlay];
[_player play];// [_player stop];
//暂停
// [_player pause];
[_player currentTime];
//播放的当前的时间
// NSTimeInterval timer = _player.currentTime;
// NSTimeInterval timerTotal = ;
}
AVAudioplayer系统播放
猜你喜欢
转载自blog.csdn.net/chuck_phonics/article/details/85039542
今日推荐
周排行