2011-12-11 4 views
1

헤드폰이 모노 터치에서 분리되어 있는지 감지하는 방법이 있습니까? AudioSessionAddPropertyListener 메서드를 찾으려고하지만 표시되지 않습니다. 이 방법은 무엇을 포팅 했습니까? 여기 헤드폰 연결 해제 - 모노 터치

애플의 문서입니다 : http://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html#//apple_ref/doc/constant_group/Audio_Session_Interruption_States

사람이 작업을 수행하는 방법에 대한 코드를보고 싶은 경우, 다음을 수행 할 수 있습니다

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); 

답변

1

헤드폰 경우 감지 할 수있는 방법이 있습니까 Monotouch에서 플러그가 뽑혀 있습니까?

는 잘 모르겠어요하지만 ... 나는 AudioSessionAddPropertyListener 방법을 찾기 위해 노력하고

하지만 표시되지 않습니다. 이 방법은 무엇을 포팅 했습니까?

AudioSessionAddPropertyListener으로의 기본 전화는 MonoTouch의 AudioSession.AddListener 정적 메서드에 매핑됩니다.

+0

우수. 그것이 내가 필요한 것입니다. API가 어떻게 매핑되는지 (MonoTouch와 기본 호출 간) 보려는 지점이 있습니까? – user472292

+0

Miguel의 rosetta stone http://tirania.org/tmp/rosetta.html은 (Objective-C) 선택자를 다룰 때 가장 좋은 자료이지만 현재 C 라이브러리의 pinvokes를 보여주지는 않습니다. 일반적으로 바인딩은 MonoDevelop IDE 자동 완성을 사용하면 가능성이있는 후보를 제안해야하는 정도로 이름을 비슷하게 유지합니다. – poupou