示例#1
0
 void startOperation(INotificationReceiver nRec)
 {
     if (useNotifications)
     {
         bool haveFocus = nMan.RequestAudioResources(nRec);
         if (haveFocus)
         {
             status.Text = "Granted";
             nRec.Start();
         }
         else
         {
             status.Text = "Denied";
         }
     }
     else
     {
         nRec.Start();
     }
 }
示例#2
0
            public void OnAudioFocusChange(AudioFocus focusChange)
            {
                switch (focusChange)
                {
                // We will take any flavor of AudioFocusgain that the system gives us and use it.
                case AudioFocus.GainTransient:
                case AudioFocus.GainTransientMayDuck:
                case AudioFocus.Gain:
                    parent.Start();
                    SetStatus("Granted");
                    break;

                // If we get any notificationthat removes focus - just terminate what we were doing.
                case AudioFocus.LossTransientCanDuck:
                case AudioFocus.LossTransient:
                case AudioFocus.Loss:
                    parent.Stop();
                    SetStatus("Removed");
                    break;

                default:
                    break;
                }
            }