Exemplo n.º 1
1
  @Override
  protected void onResume() {
    super.onResume();

    // Manage bubble popping sound
    // Use AudioManager.STREAM_MUSIC as stream type

    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

    mStreamVolume =
        (float) mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
            / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

    mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);

    mSoundPool.setOnLoadCompleteListener(
        new OnLoadCompleteListener() {

          @Override
          public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
            if (status == 0) {
              setupGestureDetector();
            } else {
              Log.i(TAG, "Unable to load sound");
              finish();
            }
          }
        });

    mSoundID = mSoundPool.load(this, R.raw.bubble_pop, 1);
  }
Exemplo n.º 2
1
 @Override
 protected void onDestroy() {
   // TODO Auto-generated method stub
   super.onDestroy();
   soundPool.release();
   soundPool = null;
 }
Exemplo n.º 3
0
 public static void playSound(Context context) {
   if (notifications == null) {
     notifications = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
     receiveOrder = notifications.load(context, R.raw.done, 1);
   }
   notifications.play(receiveOrder, 1.0f, 1.0f, 1, 0, 1);
 }
  @Override
  protected void onResume() {
    super.onResume();

    // Manage bubble popping sound
    // Use AudioManager.STREAM_MUSIC as stream type

    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

    mStreamVolume =
        (float) mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
            / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    // done
    mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);

    // done
    mSoundPool.setOnLoadCompleteListener(
        new SoundPool.OnLoadCompleteListener() {
          @Override
          public void onLoadComplete(SoundPool soundPool, int i, int i2) {
            setupGestureDetector();
          }
        });

    // done
    mSoundID = mSoundPool.load(this, R.raw.bubble_pop, 1);
  }
Exemplo n.º 5
0
 /** Stops and unloads all currently playing sounds. */
 public void unloadSounds() {
   for (Sound s : SoundList) {
     Sounds.stop(s.getID());
     Sounds.unload(s.getID());
   }
   SoundList.clear();
 }
Exemplo n.º 6
0
 private void playSound() {
   if (Bridge.getIdentityStore().getAppConfig().isAudioEnabled()) {
     SoundPool spool = new SoundPool(1, 5, 0);
     spool.setOnLoadCompleteListener(new C09742(spool));
     spool.load(this, C0901R.raw.birdy_done_1, 1);
   }
 }
Exemplo n.º 7
0
  @SuppressWarnings("deprecation")
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public void setContext(Context context) {

    mContext = context;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      AudioAttributes audioAttributes =
          new AudioAttributes.Builder()
              .setUsage(AudioAttributes.USAGE_GAME)
              .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
              .build();

      mSoundPool =
          new SoundPool.Builder().setMaxStreams(5).setAudioAttributes(audioAttributes).build();
    } else {
      mSoundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
    }

    mSoundPoolMap = new HashMap<Integer, Integer>();
    mSoundPoolMap.put(SOUND_EXPLOSION, mSoundPool.load(context, R.raw.explosion, 1));
    // TODO Add sounds corresponding to the bullet and Android Guy
    mSoundPoolMap.put(SOUND_GUY, mSoundPool.load(context, R.raw.beep4, 1));
    mSoundPoolMap.put(SOUND_BULLET, mSoundPool.load(context, R.raw.beep9, 1));

    mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    streamVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
  }
Exemplo n.º 8
0
 protected void loadSFX() {
   Context ctx = getContext();
   mWinSFX = mPool.load(ctx, R.raw.wintone, 1);
   mMissSFX = mPool.load(ctx, R.raw.ballmiss, 1);
   mPaddleSFX = mPool.load(ctx, R.raw.paddle, 1);
   mWallSFX = mPool.load(ctx, R.raw.wall, 1);
 }
Exemplo n.º 9
0
 public void button1Click(View view) {
   sp.play(soundCuckoo, 1, 1, 0, 5, 1);
   sp.play(soundCuckoo, 1, 0.5f, 0, 6, 1);
   sp.play(soundCuckoo, 0.5f, 0.5f, 0, 4, 1);
   //  sp.play(soundCuckoo, 0.1f, 1, 0, 10, 2);
   // sp.play(soundIdExplosion, 1, 1, 0, 0, 1);
 }
Exemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pear);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // player
    mMediaPlayer = MediaPlayer.create(this, R.raw.pear);
    mMediaPlayer.start();

    // object for the speaker sound
    sound = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
    soundID = sound.load(this, R.raw.pear, 1);

    // object for the check sound
    click = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
    soundID = click.load(this, R.raw.click, 1);

    // letters
    findViewById(R.id.pear_p).setOnTouchListener(this);
    findViewById(R.id.pear_e).setOnTouchListener(this);
    findViewById(R.id.pear_a).setOnTouchListener(this);
    findViewById(R.id.pear_r).setOnTouchListener(this);

    // bottom containers drag listener
    findViewById(R.id.bottom_p).setOnDragListener(this);
    findViewById(R.id.bottom_e).setOnDragListener(this);
    findViewById(R.id.bottom_a).setOnDragListener(this);
    findViewById(R.id.bottom_r).setOnDragListener(this);

    // top container drag listener
    findViewById(R.id.top_c).setOnDragListener(this);
  }
  public KeyguardViewMediator(
      Context context, PhoneWindowManager callback, LocalPowerManager powerManager) {
    mContext = context;

    mRealPowerManager = powerManager;
    mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock =
        mPM.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
    mWakeLock.setReferenceCounted(false);
    mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
    mShowKeyguardWakeLock.setReferenceCounted(false);

    mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff");
    mWakeAndHandOff.setReferenceCounted(false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(DELAYED_KEYGUARD_ACTION);
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    context.registerReceiver(mBroadCastReceiver, filter);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mCallback = callback;

    mUpdateMonitor = new KeyguardUpdateMonitor(context);

    mUpdateMonitor.registerInfoCallback(this);
    mUpdateMonitor.registerSimStateCallback(this);

    mLockPatternUtils = new LockPatternUtils(mContext);
    mKeyguardViewProperties =
        new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor);

    mKeyguardViewManager =
        new KeyguardViewManager(
            context, WindowManagerImpl.getDefault(), this, mKeyguardViewProperties, mUpdateMonitor);

    mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
    mUserPresentIntent.addFlags(
        Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);

    final ContentResolver cr = mContext.getContentResolver();
    mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1);

    mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
    String soundPath = Settings.System.getString(cr, Settings.System.LOCK_SOUND);
    if (soundPath != null) {
      mLockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mLockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
    soundPath = Settings.System.getString(cr, Settings.System.UNLOCK_SOUND);
    if (soundPath != null) {
      mUnlockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mUnlockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
  }
  /**
   * アクティビティが作られたとき実行される
   *
   * @param savedInstanceStage バンドル
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /* サウンド関連初期化 */
    map = new HashMap<Integer, Integer>();
    sePool = new SoundPool(10, AudioManager.STREAM_MUSIC, 1);
    map.put(R.raw.bakuhatsu, sePool.load(this, R.raw.bakuhatsu, 1));
    map.put(R.raw.hassya, sePool.load(this, R.raw.hassya, 1));
    map.put(R.raw.click, sePool.load(this, R.raw.click, 1));

    final Object thisObj = this;
    handler =
        new Handler() {
          public void handleMessage(Message msg) {
            super.handleMessage(msg);

            switch (msg.what) {
              case 0:
                setContentView(R.layout.title);
                titleView = (ImageView) findViewById(R.id.title_image);
                titleView.setOnTouchListener((OnTouchListener) thisObj);

                /* サウンド関連の初期化 */
                player = MediaPlayer.create((Context) thisObj, R.raw.opening);
                player.setLooping(true);
                player.start();

                break;
              case 1:
                setContentView(R.layout.main);
                // サーフェイスビューをセット
                surfaceview = (SurfaceView) findViewById(R.id.GameView);
                GameController main = new GameController(surfaceview, this);
                surfaceview.getHolder().addCallback(main);
                break;
              case 2:
                setContentView(R.layout.end);
                endView = (ImageView) findViewById(R.id.end_image);
                endView.setOnTouchListener((OnTouchListener) thisObj);

                TextView txt = (TextView) findViewById(R.id.score_text);
                txt.setText("" + ((int[]) msg.obj)[0]);

                /* サウンド関連の初期化 */
                player = MediaPlayer.create((Context) thisObj, R.raw.gameover);
                player.setLooping(true);
                player.start();

                break;
            }
          }
        };

    handler.sendEmptyMessage(0);
  }
Exemplo n.º 13
0
 /** 初始化音效 */
 public void initMusic() {
   soundp = new SoundPool(50, AudioManager.STREAM_MUSIC, 100);
   soundm = new HashMap<String, Integer>();
   soundm.put("slide", soundp.load(MainActivity.this, R.raw.slide, 1));
   soundm.put("flap", soundp.load(MainActivity.this, R.raw.flap, 1));
   soundm.put("s1", soundp.load(MainActivity.this, R.raw.squish1, 1));
   soundm.put("s2", soundp.load(MainActivity.this, R.raw.squish2, 1));
   soundm.put("k1", soundp.load(MainActivity.this, R.raw.kick1, 1));
   soundm.put("k2", soundp.load(MainActivity.this, R.raw.kick2, 1));
 }
Exemplo n.º 14
0
  private void LoadContent() {
    audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    ((Activity) context).setVolumeControlStream(AudioManager.STREAM_MUSIC);
    soundPool = new SoundPool(20, AudioManager.STREAM_RING, 100);

    curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    leftVolume = (curVolume / maxVolume);
    rightVolume = (curVolume / maxVolume);

    soundPoolMap[0] = soundPool.load(context, R.raw.coin_collect, 1);
    aff = soundPool.load(context, R.raw.coin_collect, 1);
    soundPoolMap[1] = soundPool.load(context, R.raw.cheer1, 1);
    soundPoolMap[2] = soundPool.load(context, R.raw.sound_bird, 1);
    soundPoolMap[3] = soundPool.load(context, R.raw.sound_shark, 1);
    soundPoolMap[4] = soundPool.load(context, R.raw.sound_splash, 1);
    soundPoolMap[5] = soundPool.load(context, R.raw.sound_swoosh, 1);
    soundPoolMap[6] = soundPool.load(context, R.raw.noluck, 1);
    soundPoolMap[7] = soundPool.load(context, R.raw.luck, 1);
    soundPoolMap[8] = soundPool.load(context, R.raw.start_boat, 1);

    priority = 1;
    no_loop = 0;
    normal_playback_rate = 1f;

    themePlay = MediaPlayer.create(this.context, R.raw.theme);
    themePlay.setLooping(true);
    themePlay.start();

    wavePlay = MediaPlayer.create(this.context, R.raw.wave_sound);
    wavePlay.setLooping(true);
    wavePlay.setVolume(leftVolume / 5, rightVolume / 5);
    wavePlay.start();
  }
Exemplo n.º 15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    sp = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
    sp.setOnLoadCompleteListener(this);

    soundCuckoo = sp.load(this, R.raw.cuckoo, 1);
    Log.d(LOG_TAG, "soundCuckoo = " + soundCuckoo);
  }
Exemplo n.º 16
0
  @Override
  protected void onPause() {

    if (mSoundPool != null) {
      mSoundPool.unload(mSoundID);
      mSoundPool.release();
      mSoundPool = null;
    }

    super.onPause();
  }
 public void doClick(View view) {
   switch (view.getId()) {
     case R.id.button:
       if (((ToggleButton) view).isChecked()) {
         soundPool.autoResume();
       } else {
         soundPool.autoPause();
       }
       break;
   }
 }
Exemplo n.º 18
0
  public void setupSound() {
    // Check if we're running on Android 5.0
    if (Build.VERSION.SDK_INT >= 21) {
      mSoundPool = new SoundPool.Builder().setMaxStreams(5).build();
    } else {
      mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 1);
    }

    mHitSound = mSoundPool.load(this, R.raw.click1, 1);
    mMissSound = mSoundPool.load(this, R.raw.click2, 1);
    mGameOverSound = mSoundPool.load(this, R.raw.gameover, 1);
  }
Exemplo n.º 19
0
  private void userTapped(float x, float y) {
    // Check to see if robot is pressed
    if (mRobot.wasTapped(x, y)) {
      mScore += 10;

      // hit sound
      mSoundPool.play(mHitSound, 1, 1, 1, 0, 1);
    } else {

      // miss sound
      mSoundPool.play(mMissSound, 1, 1, 1, 0, 1);
    }
  }
  /** 画面にタッチされたとき */
  public boolean onTouch(View v, MotionEvent event) {
    if (v == titleView) {
      handler.sendEmptyMessage(1);

      player.stop();
      sePool.play(map.get(R.raw.click), 0.5f, 0.5f, 0, 0, 1.0f);
    } else if (v == endView) {
      handler.sendEmptyMessage(0);

      player.stop();
      sePool.play(map.get(R.raw.click), 0.5f, 0.5f, 0, 0, 1.0f);
    }

    return false;
  }
 public void stop() {
   if (soundPool != null) {
     if (streamId != 0) {
       soundPool.stop(streamId);
       streamId = 0;
     }
     if (soundId != 0) {
       soundPool.unload(soundId);
       soundId = 0;
     }
   }
   if (isRingModeRegister) {
     registerVolumeReceiver(false);
   }
 }
Exemplo n.º 22
0
 public void load(Context context) {
   if (soundPool != null) {
     dispose();
   }
   soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
   soundPool.setOnLoadCompleteListener(this);
   Iterator<Integer> iter = soundMap.keySet().iterator();
   int i = 0;
   while (iter.hasNext()) {
     int key = iter.next();
     int soundId = soundPool.load(context, key, 1);
     loadSoundMap.put(soundId, key);
     i++;
   }
 }
Exemplo n.º 23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);

    bindService();

    Button btn = (Button) findViewById(R.id.btnBTCtest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnRSteptest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnHRSTtest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnAccTest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnStop);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnSetRun20);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnSetRunContinue);
    btn.setOnClickListener(this);

    gGraph0 = (ResultGraphDashBoard) findViewById(R.id.rgdb_0);
    gGraph0.setRangeMax(800, 1024);
    gGraph1 = (MultiGraphDashBoard) findViewById(R.id.rgdb_1);

    gGraph1.addSeries(getResources().getColor(R.color.opaque_shadow));
    gGraph1.addSeries(getResources().getColor(R.color.orange));
    gGraph1.addSeries(getResources().getColor(R.color.mint));
    gGraph1.setRangeMax(512, 1024);

    gSoundpool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
    sp1 = gSoundpool.load(this, R.raw.wood1, 1);
    sp2 = gSoundpool.load(this, R.raw.wood2, 1);
  }
Exemplo n.º 24
0
  public void btn3(View view) {

    click.play(soundID, 1, 1, 1, 0, 1);
    finish();
    Intent cat3 = new Intent(this, boot.class);
    startActivity(cat3);
  }
Exemplo n.º 25
0
  public void btn2(View view) {

    click.play(soundID, 1, 1, 1, 0, 1);
    finish();
    Intent cat2 = new Intent(this, apple.class);
    startActivity(cat2);
  }
Exemplo n.º 26
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_number6);
   mySound = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
   redaudioId = mySound.load(this, R.drawable.six, 1);
 }
Exemplo n.º 27
0
 public static void playSound(int index, float speed) {
   if (playSound) {
     float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
     streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
     mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, speed);
   }
 }
Exemplo n.º 28
0
 public static void cleanup() {
   mSoundPool.release();
   mSoundPool = null;
   mSoundPoolMap.clear();
   mAudioManager.unloadSoundEffects();
   _instance = null;
 }
  public void playSound(int index) {
    if (!mContext.getSettings().isSoundEnabled()) return; // user does not want sound

    float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f);
  }
Exemplo n.º 30
0
 private void initializeSoundClips() {
   this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
   // Load the sound
   soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
   soundPool.setOnLoadCompleteListener(
       new SoundPool.OnLoadCompleteListener() {
         @Override
         public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
           loaded = true;
         }
       });
   player1Sound = soundPool.load(this, R.raw.player1, 1);
   player2Sound = soundPool.load(this, R.raw.player2, 1);
   winnerSound = soundPool.load(this, R.raw.winner, 1);
   tieSound = soundPool.load(this, R.raw.tie, 1);
 }