I want get the current value of my iphone from my audio player in objective c. But I can't get this because is deprecated.
MPMusicPlayerController *musicPlayer;
musicPlayer.volume //This is deprecated
There are some alternatives?
I want get the current value of my iphone from my audio player in objective c. But I can't get this because is deprecated.
MPMusicPlayerController *musicPlayer;
musicPlayer.volume //This is deprecated
There are some alternatives?
As written in the developer docs you should use the VolumeView (Seen here)
Because it is a view, you cannot get the current value. I'm not sure, but maybe this code works (not tested):
MPVolumeView* volumeView = [[MPVolumeView alloc] init];
for (UIView *view in [volumeView subviews]){
if([view isKindOfClass:[UISlider class]]) {
UISlider *slider = (UISlider*) view;
CGFloat volume = slider.value; // this is the current volume
}
}
If this does not work, you can set the volume of you application by setting
slider.value = 1.0f;
in the for loop.