gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:02:39 24 4
gpt4 key购买 nike

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

最佳答案

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com