应用程序崩溃与AVAudioSession privateBeginInterruption [英] App crashes with AVAudioSession privateBeginInterruption

查看:211
本文介绍了应用程序崩溃与AVAudioSession privateBeginInterruption的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设备(音板)上测试我的应用程序,并且它以 EXC_BAD_ACCESS 崩溃,我使用了断点,错误来自 [AVAudioSession privateBeginInterruption]

I'm testing my app on device (a soundboard) and it crashes with a EXC_BAD_ACCESS, I have use Breakpoints and the error came from [AVAudioSession privateBeginInterruption]

此模式后发生崩溃:


  1. 该应用程序已启动,我们看到主菜单

  2. 按下主菜单按钮并加载音板视图(按下),此处按下一些按钮,声音为播放。

  3. 返回主菜单( [self.navigationController popViewControllerAnimated:YES];

  4. 应用程序进入后台

  5. 当应用程序进入前台并按下音板的菜单按钮时,应用程序崩溃。

  1. The app is launched, we see the main menu
  2. A main menu button is pressed and a soundboard view is loaded (push), some buttons are pressed here and sounds are played.
  3. Return to main menu ([self.navigationController popViewControllerAnimated:YES];)
  4. App enters background
  5. When app enters foreground and the menu button of the soundboard is pressed the app crashes.

我不知道这里发生了什么,我已经安装了CrashLytics,它只说:

I have no idea what is happening here, I have installed CrashLytics and it only said:

也许音频会话从内存和应用程序中释放试图访问它并失败?

Maybe the audio session gets released from memory and the app tries to access to it and fail?

音频会话初始化为 viewDidLoad

//  Initialize audio session
[[AVAudioSession sharedInstance] setDelegate: self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: nil];

UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof    (audioRouteOverride),&audioRouteOverride);  

viewDidUnload 我有

[[AVAudioSession sharedInstance] setDelegate: nil];

任何提示?

谢谢!

推荐答案

发生崩溃的原因是您已在此行中将会话委托设置为您的控制器

The crash happens because you had set the delegate of session to your controller in this line

[[AVAudioSession sharedInstance] setDelegate: self];

但没有实现所需的委托方法(中断一个)

but didn't implemented the required delegate method (interruption one)

删除委托设置行或实现委托方法来解决崩溃

either remove the delegate setting line or implement the delegate method to solve crash

这篇关于应用程序崩溃与AVAudioSession privateBeginInterruption的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆