Esempio n. 1
0
 public void startListening() {
   lawg.d("startListening()");
   //    mAudioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
   //    mAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
   //    mAudioManager.setStreamMute(AudioManager.STREAM_ALARM, true);
   //    mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
   if (mSpeechRecognizer != null) {
     mSpeechRecognizer.destroy();
   }
   mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
   mAudioManager.setStreamMute(AudioManager.STREAM_ALARM, true);
   mAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
   mAudioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
   mAudioManager.setStreamMute(AudioManager.STREAM_RING, true);
   mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
   mSpeechRecognizer.setRecognitionListener(mRecognitionListener);
   Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
   recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
   //
   // recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS,
   // 1000 * 2);
   //
   // recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 1000 * 2);
   //    recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 1000
   // * 2);
   mSpeechRecognizer.startListening(recognizerIntent);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // Handle item selection
   switch (item.getItemId()) {
     case R.id.exit:
       moveTaskToBack(true);
       return true;
     case R.id.sound:
       AudioManager volumeControl = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
       if (soundOn) {
         volumeControl.setStreamMute(AudioManager.STREAM_MUSIC, true);
         soundOn = false;
         item.setTitle("Sound On");
       } else {
         volumeControl.setStreamMute(AudioManager.STREAM_MUSIC, false);
         soundOn = true;
         item.setTitle("Sound Off");
       }
       return true;
     case R.id.ratings:
       startActivity(
           new Intent(
               Intent.ACTION_VIEW, Uri.parse("market://details?id=com.apps.tictactoe#rate")));
       return true;
     case R.id.back:
       startActivity(new Intent(this, HomeScreenActivity.class));
       return true;
     case R.id.about:
       startActivity(new Intent(this, About.class));
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Esempio n. 3
0
 private void stopSpeechRecognizer() {
   mAudioManager.setStreamMute(AudioManager.STREAM_RING, false);
   if (mSpeechRecognizer != null) {
     mSpeechRecognizer.destroy();
   }
   mSpeechRecognizer.stopListening();
 }
  protected void setRingTo(boolean on) {

    if (Log.DEBUG) Log.d("on = " + on);

    if (on && _ringIsMuted) {
      _ringIsMuted = false;

      _audioManager.setStreamMute(AudioManager.STREAM_RING, false);
      _muteCounter--;
    }

    if (!on && !_ringIsMuted) {
      _ringIsMuted = true;

      _audioManager.setStreamMute(AudioManager.STREAM_RING, true);
      _muteCounter++;
    }
  }
        public void onStopTrackingTouch(SeekBar bar) {
          if (!mInstantSeeking) mPlayer.seekTo((mDuration * bar.getProgress()) / 1000);

          show(sDefaultTimeout);
          mHandler.removeMessages(SHOW_PROGRESS);
          mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
          mDragging = false;
          mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
        }
  protected void setAllOtherSoundsTo(boolean on) {

    if (Log.DEBUG) Log.d("on = " + on);

    if (on && _otherSoundsIsMuted) {
      _otherSoundsIsMuted = false;

      _audioManager.setStreamMute(AudioManager.STREAM_ALARM, false);
      _audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
      _audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, false);
    }

    if (!on && !_otherSoundsIsMuted) {
      _otherSoundsIsMuted = true;

      _audioManager.setStreamMute(AudioManager.STREAM_ALARM, true);
      _audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
      _audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
    }
  }
Esempio n. 7
0
 @Override
 public void onStartTrackingTouch(SeekBar bar) {
   mDragging = true;
   show(3600000);
   mHandler.removeMessages(SHOW_PROGRESS);
   if (mInstantSeeking) mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
   if (mInfoView != null) {
     mInfoView.setText("");
     mInfoView.setVisibility(View.VISIBLE);
   }
 }
Esempio n. 8
0
 @Override
 public void onStopTrackingTouch(SeekBar bar) {
   if (!mInstantSeeking) mPlayer.seekTo((mDuration * bar.getProgress()) / 1000);
   if (mInfoView != null) {
     mInfoView.setText("");
     mInfoView.setVisibility(View.GONE);
   }
   show(sDefaultTimeout);
   mHandler.removeMessages(SHOW_PROGRESS);
   mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
   mDragging = false;
   mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
 }
  private void muteSpeaker() {
    Log.i("onToggleIsChecked", "ToggleClick Is On");
    // turn ringer silent
    amanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    Log.i("RINGER_MODE_SILENT", "Set to true");

    // turn off sound, disable notifications
    amanager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
    Log.i("STREAM_SYSTEM", "Set to true");
    // notifications
    amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
    Log.i("STREAM_NOTIFICATION", "Set to true");
    // alarm
    amanager.setStreamMute(AudioManager.STREAM_ALARM, true);
    Log.i("STREAM_ALARM", "Set to true");
    // ringer
    amanager.setStreamMute(AudioManager.STREAM_RING, true);
    Log.i("STREAM_RING", "Set to true");
    // media
    amanager.setStreamMute(AudioManager.STREAM_MUSIC, true);
    Log.i("STREAM_MUSIC", "Set to true");
  }
  private void unmuteSpeaker() {
    Log.i("onToggleIsChecked", "ToggleClick Is Off");

    // turn ringer silent
    amanager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    Log.i(".RINGER_MODE_NORMAL", "Set to true");

    // turn on sound, enable notifications
    amanager.setStreamMute(AudioManager.STREAM_SYSTEM, false);
    Log.i("STREAM_SYSTEM", "Set to False");
    // notifications
    amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false);
    Log.i("STREAM_NOTIFICATION", "Set to False");
    // alarm
    amanager.setStreamMute(AudioManager.STREAM_ALARM, false);
    Log.i("STREAM_ALARM", "Set to False");
    // ringer
    amanager.setStreamMute(AudioManager.STREAM_RING, false);
    Log.i("STREAM_RING", "Set to False");
    // media
    amanager.setStreamMute(AudioManager.STREAM_MUSIC, false);
    Log.i("STREAM_MUSIC", "Set to False");
  }
        public void onShutter() {
          // TODO Auto-generated method stub

          AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
          mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);

          try {
            player.prepare();
          } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }

          player.start();
        }
  /**
   * Init
   *
   * @param targetWords Words to track
   * @param parent Main Activity parent (that implements speech listener)
   */
  public void init(String[] targetWords, MainActivity parent) {

    // do only once
    if (wa == null) {

      // preempt beeping noise of speech recognizer by turning it off
      AudioManager amanager =
          (AudioManager) parent.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
      amanager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
    }

    // store parent
    this.parent = parent;

    // initialize word activator
    boolean needGC = (wa != null);
    wa = new WordActivator(parent, parent, targetWords);
    if (needGC) {
      System.gc();
    }
  }
  public static void adjust(int keyCode, boolean down) {
    AudioManager mAudioManager =
        (AudioManager) Receiver.mContext.getSystemService(Context.AUDIO_SERVICE);

    if (RtpStreamReceiver.speakermode == AudioManager.MODE_NORMAL)
      if (down ^ mAudioManager.getStreamVolume(stream()) == 0)
        mAudioManager.setStreamMute(stream(), down);
    if (down && down_time == 0) down_time = SystemClock.elapsedRealtime();
    if (!down ^ RtpStreamReceiver.speakermode != AudioManager.MODE_NORMAL)
      if (SystemClock.elapsedRealtime() - down_time < 500) {
        if (!down) down_time = 0;
        if (ogain > 1)
          if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            if (gain != ogain) {
              gain = ogain;
              return;
            }
            if (mAudioManager.getStreamVolume(stream())
                == mAudioManager.getStreamMaxVolume(stream())) return;
            gain = ogain / 2;
          } else {
            if (gain == ogain) {
              gain = ogain / 2;
              return;
            }
            if (mAudioManager.getStreamVolume(stream()) == 0) return;
            gain = ogain;
          }
        mAudioManager.adjustStreamVolume(
            stream(),
            keyCode == KeyEvent.KEYCODE_VOLUME_UP
                ? AudioManager.ADJUST_RAISE
                : AudioManager.ADJUST_LOWER,
            AudioManager.FLAG_SHOW_UI);
      }
    if (!down) down_time = 0;
  }
Esempio n. 14
0
 public void onStartTrackingTouch(SeekBar bar) {
   mDragging = true;
   show(3600000);
   mHandler.removeMessages(SHOW_PROGRESS);
   if (mInstantSeeking) mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
 }