zoukankan      html  css  js  c++  java
  • iOS 8 录音重放出现 OSStatus error 1685348671 / 2003334207 问题的解决办法

    许多录音类 APP 都提供录音回放功能,大家在做这类 APP 的时候也经常会遇到这个需求。当大家用以前的套路在 iOS 8 上录音的时候,在模拟器上跑得挺好的,但是一上真机就跪了,为什么?因为真机底层是真实的硬件,跟模拟器还是有一些差别的,例如真机支持硬件解码等等。

    在 iOS 8 上,录音并播放需要在录音前就申请“录音并播放”的 session(swift):

    func setSessionPlayAndRecord() {
        let session:AVAudioSession = AVAudioSession.sharedInstance()
        var error: NSError?
        if !session.setCategory("AVAudioSessionCategoryPlayAndRecord", withOptions: AVAudioSessionCategoryOptions.DefaultToSpeaker, error:&error) {
            println("could not set session category")
            if let e = error {
                println(e.localizedDescription)
            }
        }
        if !session.setActive(true, error: &error) {
            println("could not make session active")
            if let e = error {
                println(e.localizedDescription)
            }
        }
    }

    之后再开始录音,等录音结束后就可以正常播放啦。

     

     
     
     
  • 相关阅读:
    es6---let和const
    node.js开发指南系列(1)partial is not defined
    input唤起键盘影响移动端底部fixed定位
    vue滑动吸顶以及锚点定位
    nodejs开发准备工作(2)
    nodejs开发准备工作(1)
    php基础小知识
    php基础
    git基础
    ps基础
  • 原文地址:https://www.cnblogs.com/Cheetah-yang/p/4669907.html
Copyright © 2011-2022 走看看