How to get and set the volume in iOS xamarin.forms?
I have written a dependacy service in android which sets and gets the volume of the music stream on android.
I want to have a slider with the current volume set by default and allower user to set the volume by sliding the slider. Also I would like to get the maximum allowed volume level for setting the maximum limit of the slider.
Here is how I have done in android, and is working perfectly on andriod device:
public int MaxVolume()
{
AudioManager audioMan = (AudioManager)global::Android.App.Application.Context.GetSystemService(Context.AudioService);
return audioMan.GetStreamMaxVolume(Android.Media.Stream.Music);
}
public void SetVolume(int volume)
{
AudioManager audioMan = (AudioManager)global::Android.App.Application.Context.GetSystemService(Context.AudioService);
audioMan.SetStreamVolume(Android.Media.Stream.Music, volume, 0);
}
public int GetCurrentVolume()
{
AudioManager audioMan = (AudioManager)global::Android.App.Application.Context.GetSystemService(Context.AudioService);
return audioMan.GetStreamVolume(Android.Media.Stream.Music);
}
How do I achieve same on iOS? I tried float volume = AVAudioSession.SharedInstance().OutputVolume;
, but doesn't give me volume.