作爲主題...有可能嗎?iphone,即使在靜音或靜音模式下如何播放聲音?
感謝
再次,我重視的代碼如下,請其步驟是錯誤的.thanks。
//@step
AudioSessionInitialize (NULL, NULL, NULL, NULL);
AudioSessionSetActive(true);
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
OSStatus error = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof(sessionCategory),&sessionCategory);
if (error)
printf("ERROR AudioSessionSetProperty ! %d\n", error);
//@step
NSString* filePath = @"AlarmClockBell.caf";
[Util restoreResourceFile:filePath];
filePath =[Util getFileFullPathFromSysDoc:filePath];
NSURL *soundFileURL = [NSURL fileURLWithPath:filePath];
NSError* error ;
AVAudioPlayer * audioPalyer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: &error];
if (nil == audioPalyer)
{
AppTrace3(self, @"Faild to play", soundFileURL, error);
return FALSE;
}
[audioPalyer prepareToPlay];
[audioPalyer setVolume: 5 ];
[audioPalyer setDelegate: self];
audioPalyer.numberOfLoops = 10;
[audioPalyer play];
感謝...
此代碼是否最終工作?您是否解決了您的問題? – 2011-03-18 20:46:18