【问题标题】:iOS 8 sound for app doesn't work like it did in iOS 7应用程序的 iOS 8 声音不像在 iOS 7 中那样工作
【发布时间】:2014-11-29 17:45:10
【问题描述】:

我在 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);

【问题讨论】:

  • IIRC 您需要在设备上进行测试,而不是在模拟器中。

标签: ios iphone


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    相关资源
    最近更新 更多