gpt4 book ai didi

iphone - iOS后台音频链接器错误

转载 作者:行者123 更新时间:2023-11-29 11:02:03 24 4
gpt4 key购买 nike

错误;

undefined symbols for architecture i386:
"_AudioSessionSetProperty", referenced from:
-[AppDelegate applicationDidFinishLaunching:] in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我正在使用的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

// Set AudioSession
NSError *sessionError = nil;
[[AVAudioSession sharedInstance] setDelegate:self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];

/* Pick any one of them */
// 1. Overriding the output audio route
//UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
//AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride);

// 2. Changing the default output audio route
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);

[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];

return YES;
}

(来自 https://devforums.apple.com/thread/90684?start=0&tstart=0this app was developed and works fine under ios 5.0, but crashes under ios 4.3How do I get my AVPlayer to play while app is in background? )

最后是我的 plist:

enter image description here问题是什么?在我的 appdelegate 标题中:

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, AVAudioPlayerDelegate> {

}

似乎一切都是进口的。我做错了什么?

最佳答案

这就是我在后台播放音频的方式:

// Allow to play in background
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

这也修复了上面的错误:

通过右击框架 -> 添加 -> 现有框架,将 AudioToolbox 和 AVFoundation 框架添加到您的项目中

关于iphone - iOS后台音频链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448190/

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