2014-09-18 1 views
2

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에서는 더 이상 작동하지 않습니다.이 문제를 해결하는 방법이 궁금합니다.

+0

모바일 플랫폼 용으로 개발하지는 않지만 iOS 8 용 SDK의 업데이트 된 버전을 사용해 보지 않겠습니까? – cybermonkey

+0

@zyboxinternational 그게 무슨 뜻이야? 아마추어처럼 들려서 미안해. –

+0

에서와 같이 iOS 8은 새로운 기능에 액세스하고 기존 기능과의 호환성을 제공하기 위해 업데이트 된 SDK가 필요할 수 있습니다. – cybermonkey

답변

0

동일한 문제가 있습니다. 나는 또한 종료 할 때 일시 중지하고 오디오를 일시 중지했다 - iOS7에서 훌륭하게 작동했다. 그러나 ios 8은 작동하지 않는다. ios7 및 ios8 장치에서 xcode6과 베타 xcode6.1을 모두 시도했다. ios7에는 문제가 없으며 의도 한대로 작동합니다. 그러나 ios8은 나에게 문제를주고 일시 중지하거나 오디오를 일시 중지하지 않습니다. 정말 귀찮습니다 !!

0

오디오 및 에어 플랙 항목은 배경 모드는입니다.이 기능은 저에게 유용합니다.