音频

音效播放

框架: AVFoundation

  • 创建
AudioServicesCreateSystemSoundID(CFURLRef  inFileURL, SystemSoundID *outSystemSoundID)
  • 播放
 AudioServicesPlaySystem(Alert)Sound(SystemSoundID  inSystemSoundID)

音乐播放

框架: AVFoundation

  • 创建
AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:NULL];
  • 暂停
[self.player pause];
  • 播放
// 更改播放进度
self.player.currentTime = 10;
[self.player play];

录音

  • 创建
AVAudioRecorder *recorder = [[AVAudioRecorder alloc]initWithURL:url settings:nil error:nil];
  • 开始 & 暂停
if (self.recorder.isRecording) {
        [self.recorder stop];
    }else{
        [self.recorder record];
    }

你可能感兴趣的:(音频播放)