I/O를 실행하는 오디오 세션 비활성화. 오디오 세션을 비활성화하기 전에 모든 I/O를 중지하거나 일시 중지해야합니다.배경 음악이 전경으로 들어갈 때 iOS8에서 재생되지 않습니다.
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
SKView *view = (SKView *)self.window.rootViewController.view;
((MyScene *)view.scene).gamePaused = YES;
[[AVAudioSession sharedInstance] setActive:NO error:nil];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
[[AVAudioSession sharedInstance] setActive:NO error:nil];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
[[AVAudioSession sharedInstance] setActive:YES error:nil];
}
다음은 AppDelegate.m 파일의 코드입니다. 앱을 종료하고 다시 입력 할 때마다 내 게임의 배경 음악이 다시 재생되지 않습니다. 이 코드는 iOS7에서 잘 작동하지만 iOS8에서는 더 이상 작동하지 않습니다.이 문제를 해결하는 방법이 궁금합니다.
모바일 플랫폼 용으로 개발하지는 않지만 iOS 8 용 SDK의 업데이트 된 버전을 사용해 보지 않겠습니까? – cybermonkey
@zyboxinternational 그게 무슨 뜻이야? 아마추어처럼 들려서 미안해. –
에서와 같이 iOS 8은 새로운 기능에 액세스하고 기존 기능과의 호환성을 제공하기 위해 업데이트 된 SDK가 필요할 수 있습니다. – cybermonkey