简体   繁体   English

设备在后台播放音频,模拟器不播放

[英]Device plays audio in background, Simulator does not

Here's the issue: 这是问题所在:

  • When running my app on a device, audio play in the background. 在设备上运行我的应用程序时,音频会在后台播放。
  • When running my app on the simulator, the audio stop playing in background, and resumes when app is again in foreground. 在模拟器上运行我的应用程序时,音频会在后台停止播放,并在应用程序再次进入前景时恢复播放。

I have done the following: 我已经完成以下工作:

  • .plist background mode is audio . .plist背景模式为audio
  • I call code below in didFinishLaunchingWithOptions 我在didFinishLaunchingWithOptions调用以下代码

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
[[AVAudioSession sharedInstance] setActive:YES error:&error];

What am I missing? 我想念什么? I checked that error is nil after both methods. 两种方法后,我都检查error nil

I'm quite sure the simulator doesn't support background audio, unfortunately. 不幸的是,我非常确定模拟器不支持背景音频。 You'll have to resort to testing on real devices. 您将不得不在真实设备上进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 背景音频在iOS模拟器上可运行,但不能在设备上运行 - background audio working on iOS simulator but not device Swift:声音在模拟器上播放,但不在设备上播放 - Swift: Sound plays on simulator but not on device avplayer在模拟器上而不是在设备上播放视频吗? - avplayer plays video on simulator not on device? iOS背景音频流(m3u)在设备上不起作用(但在模拟器中可以) - iOS background Audio Stream (m3u) doesn't work on device (but does in simulator) 音频播放器可以在后台的iOS模拟器上运行,但不能在iOS设备上使用(相同版本) - Audio player work on iOS simulator in Background but does not on iOS device (same version) 我的音板应用程序在模拟器上播放声音,但不在设备上播放声音 - My soundboard app plays sound on the simulator, but not the device Javascript音频在浏览器中播放,但不能在iOS设备上播放 - Javascript audio plays in browser but not on iOS device 音频在后台播放,但没有声音Cordova 3+ IOS - Audio plays in background but no sound Cordova 3+ IOS iOS 对讲机应用在后台播放音频 - iOS Walkie Talkie app plays audio in background 为什么UITableView中的空白单元格在设备上具有灰色背景,但在模拟器上却没有? - Why does an empty cell in UITableView has grey background on device but not on simulator?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM