OGeek|极客世界-中国程序员成长平台

标题: 应用程序的 iOS 8 声音不像在 iOS 7 中那样工作 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:03
标题: 应用程序的 iOS 8 声音不像在 iOS 7 中那样工作

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

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

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



Best Answer-推荐答案


我在音频方面遇到了同样的问题,但经过一番搜索,我发现了一个适用于 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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4