iOS 8 应用程序的声音不像 iOS 7 那样工作

标签 ios iphone

我在 Xcode 5.1.1 中开发了我的游戏应用程序。昨天我下载了 Xcode 6.1.1。在 Xcode 6.1.1 中,当我上传任何 iOS 8.1 模拟器时,声音不起作用。然而,声音对于所有 iOS 7 模拟器来说都运行得非常好。我正在使用 AudioToolbox.framework 来处理我的 .aiff 声音。 iOS 7 和 iOS 8 应用程序之间的编码有区别吗?还是别的什么?

在我的 ViewDidLoad 中,声音代码...

 NSURL *SwishURL =[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"SwishSound" ofType:@"aiff"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)SwishURL, &SwishID);

最佳答案

我在音频方面也遇到了同样的问题,但经过一些搜索,我找到了一个适用于 Xcode 6.1.1 here 的解决方案。 .

实现是这样的:

@import AudioToolBox;
@import AVFoundation;

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"sound_effect" ofType: @"wav"];
NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
AVAudioPlayer *sound = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:nil];

[sound play];

关于iOS 8 应用程序的声音不像 iOS 7 那样工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27205105/

相关文章:

ios - 属性只是 getter 而不是 setter

iphone - CALayer的效率及极限是多少

ios - 在数组中查找对象的最佳方法

ios - xcode 6 Mac 10.9 中的 Protocol Buffer

ios - 使用 AVCaptureVideoDataOutput 录制视频

iphone - 在 iPhone 和 iPad 上显示网站的整个宽度

iphone - 是否可以创建一个应用程序,该应用程序通过短信自动回复电话,并自动回复收到的短信和电子邮件?

ios - Swift 类扩展 - 发送到实例的无法识别的选择器

html - 我的 iPhone 6 获取 iPhone 5 媒体查询

iphone - 如何阻止 UIView 上的转换