我有一個非常基本的音頻組件的應用程序:與AVAudioPlayer(歌曲文件名存儲爲數組)一起循環播放背景歌曲集。一切都一直工作好幾個月,但iOS 10崩潰爲我的許多用戶(每天數千)。iOS 10上的AVFAudio播放崩潰
問題是,我無法弄清楚iOS 10中發生了什麼變化。每當用戶鎖定他們的設備時,似乎都會發生這種情況,特別是在音樂完成淡出的瞬間(它不會做背景音頻,因此應用程序會自動淡出音樂)。
在那一刻,我得到這個每次:
2016-09-22 17:06:39.439979 TerraGenesis[8533:2459778] [aurioc] 889: failed: '!pla' (enable 2, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-09-22 17:06:39.443348 TerraGenesis[8533:2459778] [aurioc] 889: failed: '!pla' (enable 2, outf< 2 ch, 44100 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-09-22 17:06:39.445339 TerraGenesis[8533:2459778] [central] 54: ERROR: [0x1b50d6c40] >avae> AVAudioEngineGraph.mm:2515: PerformCommand: error 561015905
2016-09-22 17:06:39.446646 TerraGenesis[8533:2459778] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error 561015905'
*** First throw call stack:
(0x1904781c0 0x18eeb055c 0x190478094 0x1a99d978c 0x1a99ed170 0x1a99ede58 0x1a9a5b3a0 0x1a9a5a6b0 0x1a9a5a640 0x1a0228580 0x1a020cff8 0x19041222c 0x190411930 0x1904116ac 0x190480b9c 0x190353bf4 0x190e5a6bc 0x1963284a0 0x19654df40 0x19655c3ec 0x196547ae8 0x19654776c 0x196879034 0x191febbd4 0x192019904 0x192019770 0x192019b18 0x190426278 0x190425bc0 0x1904237c0 0x190352048 0x191dd5198 0x19632b818 0x196326550 0x1001c1428 0x18f3345b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
這裏的堆棧跟蹤:
Fatal Exception: com.apple.coreaudio.avfaudio
0 CoreFoundation 0x18d45c1c0 __exceptionPreprocess
1 libobjc.A.dylib 0x18be9455c objc_exception_throw
2 CoreFoundation 0x18d45c094 +[NSException raise:format:]
3 AVFAudio 0x1a6a7578c AVAE_RaiseException(NSString*, ...)
4 AVFAudio 0x1a6a89170 AVAudioEngineGraph::PerformCommand(AUGraphNode&, AVAudioEngineGraph::ENodeCommand, void*, unsigned int) const
5 AVFAudio 0x1a6a89e58 AVAudioEngineGraph::Initialize()
6 AVFAudio 0x1a6af73a0 AVAudioEngineImpl::Initialize()
7 AVFAudio 0x1a6af66b0 AVAudioEngineImpl::Start(NSError**)
8 AVFAudio 0x1a6af6640 -[AVAudioEngine startAndReturnError:]
9 SceneKit 0x19d20c580 CPP3DAudioEngine::GetAVEngine()
10 SceneKit 0x19d1f0ff8 -[SCNView _enterBackground:]
這裏是我的代碼。這是我以任何方式處理音頻的唯一部分代碼。
-(void)playNextSong {
int musicPlaybackIndex = [[[NSUserDefaults standardUserDefaults] objectForKey:@"musicPlaybackIndex"] intValue];
NSURL *soundFileURL = [NSURL fileURLWithPath:[_musicPlaylist objectAtIndex:musicPlaybackIndex]];
_musicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
_musicPlayer.volume = 0.15;
_musicPlayer.delegate = self;
[_musicPlayer prepareToPlay];
[_musicPlayer play];
if(musicPlaybackIndex+1 < [_musicPlaylist count]) {
musicPlaybackIndex++;
} else {
musicPlaybackIndex = 0;
}
}
我看到的iPhone手機,ipad這樣的碰撞,和iPod touch,但僅僅在iOS 10.0.0和10.0.1。我一直在尋找那些「[aurioc]」電話幾個小時,但我找不到任何有用的東西,它用我無法解析的行話寫成。
任何人都可以告訴我我可能做錯了什麼,或者幫助指出我在iOS 10中AVAudioPlayer可能改變的方向?
謝謝!!! Apple拒絕了我嘗試啓用背景音頻的更新,因爲我沒有真正使用它,只是簡單地調用'[_sceneView audioEngine];'似乎修復了它。再次感謝! – Nerrolken
當SceneKit應用程序正在運行時,選項2似乎停止(並阻止)其他應用程序的背景音頻播放 - 嘗試了它,似乎解決了問題,但我開始接受用戶的投訴。 選項1似乎工作,並沒有停止其他背景音頻(從我的測試到目前爲止) – StephenT
我沒有得到scnView.audioEngine,這是什麼意思? – OtakuFitness