0
であることができます:私はここに ObjectiveC AVAudioPlayerのボリュームは、私はAVAudioPlayerしかしnonesについてかなり多くの記事を見てきました0
が私のコードである(それは8.3.2にアップグレードする前に、Xcodeのと連携するために使用さにもかかわらず)もう音を取得することはできません:AVAudioPlayer *audioPlayerObj;
AVAudioSession *session;
[...]
- (IBAction)playSound:(id)sender {
audioPlayerObj.delegate = self;
if(playButton.isSelected){
playButton.selected=NO;
(void) [audioPlayerObj stop];
}
else{
session = nil;
{NSError * _error;
session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback
error:&_error];
[session setActive:YES error:&_error];
if(_error !=nil)
{ NSLog(@"could not init the audio player session %@ ", _error);
}
}
NSString * tune =[NSString stringWithFormat:@"%@.wav",[pickerViewArray objectAtIndex:[pickerView selectedRowInComponent:0]]];
NSString *path =[[NSBundle mainBundle] pathForResource:tune ofType:@""];
NSURL * actualFilePath= [NSURL fileURLWithPath:path];
NSError *error;
(void)[audioPlayerObj initWithContentsOfURL:actualFilePath error:&error];
[audioPlayerObj prepareToPlay];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
[audioPlayerObj setVolume:0.99 fadeDuration: 1];
}
NSLog(@"syst volume : %f", [session outputVolume]);
NSLog(@"vol : %f\n",[audioPlayerObj volume]);
if(error !=nil)
{ NSLog(@"could not init the audio player %@ ", error);
audioPlayerObj=nil;
}
else
{
(void) [audioPlayerObj setNumberOfLoops:-1 ];
(void) [audioPlayerObj play];
NSLog(@"playing with vol : %f\n",[audioPlayerObj volume]);
[audioPlayerObj setVolume:0.99 fadeDuration: 1];
playButton.selected=YES;
}
}
`
出力は、そのボリュームを上げる方法上の任意のヒントをいただければ幸いです syst volume : 0.476119 vol : 0.000000 playing with vol : 0.000000
です。ビューにはMPVolumeView
もありますが、その上にある操作はシステムのボリュームのみを変更します。
はこの 'AVAudioSession * audioSession = [AVAudioSession sharedInstance]をしてみてください。 [audioSession setCategory:AVAudioSessionCategoryPlaybackエラー:なし]; ' –
@pawan:上記の投稿されたコードは既にAVaudiosessionを設定しています。私はあなたの提案を試してうれしいですが、 – toto