SJAudioPlayer
是一个基于 Audio Queue 实现的音频流播放器,其支持以下功能:
- 播放本地音频文件和远程音频文件;
- 缓存远程音频数据到本地;
- 倍速播放音频;
- 恢复或暂停播放音频时,音频音量淡入淡出;
- 处理打断事件和拔出耳机事件;
- 监听远程音频数据的下载进度和播放状态的切换;
NSString *path = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:path];
SJAudioPlayer *player = [[SJAudioPlayer alloc] initWithUrl:url delegate:self];
[player play];
NSURL *url = [NSURL URLWithString:urlString];
SJAudioPlayer *player = [[SJAudioPlayer alloc] initWithUrl:url delegate:self];
[player play];
self.player.playRate = 1.5;
- (void)audioPlayer:(SJAudioPlayer *)audioPlayer statusDidChanged:(SJAudioPlayerStatus)status
{
}
- (void)audioPlayer:(SJAudioPlayer *)audioPlayer updateAudioDownloadPercentage:(float)percentage
{
}
- (void)audioPlayer:(SJAudioPlayer *)audioPlayer errorOccurred:(NSError *)error
{
}