0
我需要在iOS中制作一个应用程序,在其功能期间发出不同的声音,如“嘟嘟”。在我的应用程序中减少/减少背景音频
我用MPMusicPlayerController实现了与后台ipod的交互。
的probleme:
我没有听到“嘟”由于音乐从iPod的音量。 我需要减少iPod的音量,但不能减少我的应用程序的音量。 tomtom应用程序使得当演讲者提供关于要采取的方向的信息。但是我不知道怎么做。
我试试这个代码:
- (void)playSoundCountDown{
NSError *errorObject = nil;
[[AVAudioSession sharedInstance]setCategory:AVAudioSessionCategoryAmbient error:&errorObject];
if (errorObject) {
NSLog(@"Error setting category! %@",errorObject);
}
NSString *path = [[NSBundle mainBundle] pathForResource:@"countDownFiveToOne" ofType:@"caf"];
theSound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
theSound.delegate = self;// (AVAudioPlayer *theSound;)
[theSound setVolume:0.4f];
[theSound play];
float volumeDecrease = 0.2f;
MPMusicPlayerController* iPodMusicPlayer = [MPMusicPlayerController iPodMusicPlayer];
[iPodMusicPlayer setVolume:volumeDecrease];
}
但“setVolume”降低了设备的所有声音的音量,包括我的应用程序的声音......
我需要你的帮助。
谢谢。
十分感谢了很多,它的作品! – Lumi