Monotouch でヘッドホンが抜かれているかどうかを検出する方法はありますか? メソッドを探していますAudioSessionAddPropertyListener
が、見つかりません。このメソッドは何を移植しましたか?
Apple のドキュメントは次のとおりです。
これを行う方法のコードを誰かが見たい場合は、次の操作を実行できます。
AudioSession.PropertyListener p = delegate(AudioSessionProperty prop, int size, IntPtr data) {
NSDictionary propertyDictionary = new NSDictionary(data);
if (propertyDictionary.ContainsKey(NSObject.FromObject("OutputDeviceDidChange_OldRoute")))
{
string oldRoute = propertyDictionary.ValueForKey(new NSString("OutputDeviceDidChange_OldRoute")).ToString();
if (oldRoute == "Headphone")
{
if (audioPlayer != null)
{
audioPlayer.Pause();
}
}
}
};
AudioSession.AddListener(AudioSessionProperty.AudioRouteChange, p);