2

I am trying to hide or disable the hud from showing up whenever you press the volume button. I am also trying to disable volume change whenever you press the volume button. This is in Xamarin.IOS please help me.

I was able to get a listener when you press the volume button but it only works if the volume changed, if the volume is at 0 it will not be triggered.

public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        var session = AVAudioSession.SharedInstance();
        session.SetActive(true);
        session.AddObserver(this, "outputVolume", NSKeyValueObservingOptions.New, IntPtr.Zero);

    }

    public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
    {
        MyCameraClass.StartScanning();
    }
  • Possible duplicate of [Cleanest way of capturing volume up/down button press on iOS 8](https://stackoverflow.com/questions/28193626/cleanest-way-of-capturing-volume-up-down-button-press-on-ios-8) – jgoldberger - MSFT Nov 28 '18 at 21:46

1 Answers1

1

I don't think Apple allows you to do that. The user expects certain things to happen when the volume button is pressed and a developer should not be able to change that. For me, I would think something was wrong if I pressed the volume button and did not see the HUD letting me know that my volume is changing. The fact that your app is running would not occur to me as a reason for this and I might reboot my device thinking something has gone wrong at the OS level.

And there is a duplicate question here: Cleanest way of capturing volume up/down button press on iOS 8

jgoldberger - MSFT
  • 5,978
  • 2
  • 20
  • 44