我已经创建了AVAudioPlayer
,现在我想在用户单击按钮时将其静音。
这是我尝试过的:
player.volume = 1.0 //when first time i initiate my player
- (IBAction)speakerOnOff:(id)sender {
if (player.volume == 1.0) {
[player setVolume: 0.0];
NSLog(@"1volume is:%f",player.volume);
}else if (player.volume == 0.0) {
[player setVolume: 1.0];
NSLog(@"2volume is:%f",player.volume);
}
}