App crashes when playing audio on iOS13.1

前端 未结 3 415
无人及你
无人及你 2020-12-29 06:41

I am building an app that runs sound files from within the main bundle with a url. When I tested this on iOS 13, everything is fine. But with the new update of 13.1 I am get

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 07:17

    Add below code in AppDelegate.swift

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
    
        let audioSession = AVAudioSession.sharedInstance()
        do {
            try audioSession.setCategory(AVAudioSession.Category.playback)
        }
        catch {
            print("Setting category to AVAudioSessionCategoryPlayback failed.")
        }
        return true
    }
    

提交回复
热议问题