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); }
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 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); } }
public void btn2(View view) { click.play(soundID, 1, 1, 1, 0, 1); finish(); Intent cat2 = new Intent(this, apple.class); startActivity(cat2); }
public void btn3(View view) { click.play(soundID, 1, 1, 1, 0, 1); finish(); Intent cat3 = new Intent(this, boot.class); startActivity(cat3); }
public void remindUser() { soundpool.play(bikebell, 1.0f, 1.0f, 1, 0, 1.0f); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int icon = R.drawable.icon25; long when = System.currentTimeMillis(); int minutes = (int) (when - trip.startTime) / 60000; CharSequence tickerText = String.format("Still recording (%d min)", minutes); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0xffff00ff; notification.ledOnMS = 300; notification.ledOffMS = 3000; Context context = this; CharSequence contentTitle = "Cycle Atlanta - Recording"; CharSequence contentText = "Tap to see your ongoing trip"; Intent notificationIntent = new Intent(context, RecordingActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); final int RECORDING_ID = 1; mNotificationManager.notify(RECORDING_ID, notification); }
public void btn1(View view) { click.play(soundID, 1, 1, 1, 0, 1); finish(); Intent cat1 = new Intent(this, cow.class); startActivity(cat1); }
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); }
/** * 播放拨号响铃 * * @param sound * @param number */ protected int playMakeCallSounds() { try { // 最大音量 float audioMaxVolumn = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING); // 当前音量 float audioCurrentVolumn = audioManager.getStreamVolume(AudioManager.STREAM_RING); float volumnRatio = audioCurrentVolumn / audioMaxVolumn; audioManager.setMode(AudioManager.MODE_RINGTONE); audioManager.setSpeakerphoneOn(false); // 播放 int id = soundPool.play( outgoing, // 声音资源 0.3f, // 左声道 0.3f, // 右声道 1, // 优先级,0最低 -1, // 循环次数,0是不循环,-1是永远循环 1); // 回放速度,0.5-2.0之间。1为正常速度 return id; } catch (Exception e) { return -1; } }
@Override public void run() { Log.d(TAG, "runnableActualizarPantalla()"); flip.showNext(); sonidoCosas.play(sonidoCosasID[contadorPalabras], 1, 1, 1, 0, 1); nHandler.postDelayed(nextPantalla, 1500); }
@Override public void run() { Log.d(TAG, "runnable actualizarPantallaP"); flip.setDisplayedChild(1); sonidoCosas.play(sonidoCosasID[contadorPalabras], 1, 1, 1, 0, 1); bHandler.postDelayed(nextPantallaP, 1500); }
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); }
private void doNotify( Intent i, String contentTitle, List<Message> messages, int notificationCode, boolean withSound) { PendingIntent contentIntent = PendingIntent.getActivity(mContext, notificationCode, i, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(contentTitle) .setTicker(messages.get(0).getContent()) .setContentText(messages.get(0).getContent()); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String[] lastMessages = new String[Math.min(messages.size(), MAX_MESSAGES_PER_GROUP)]; inboxStyle.setBigContentTitle(contentTitle); for (int j = 0; j < lastMessages.length; j++) { inboxStyle.addLine(messages.get(j).getContent()); } builder.setStyle(inboxStyle); builder.setNumber(messages.size()); builder.setContentIntent(contentIntent); builder.setAutoCancel(true); mNotificationManager.notify(notificationCode, builder.build()); if (withSound) { mSoundEffectsPool.play(newMessageSoundId, 1.0f, 1.0f, 0, 0, 1); } }
public void playSound(int index) { if (!isSoundTurnedOn()) return; if (mAudioManager != null) { int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f); } }
/** * Memainkan note ke-'index' dari alat musik yang sedang disimulasikan * * @param index note yang ingin dimainkan */ public void play(int index) { AudioManager audioManager = (AudioManager) activity.getSystemService(activity.AUDIO_SERVICE); float actualVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); float maxVolume = (float) audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = actualVolume / maxVolume; soundPool.play(activeSoundId[index], volume, volume, 1, 0, 1f); }
public void play(Sound sound) { Integer soundId = sound.getSoundId(); if (soundId == null) { return; } mSoundPool.play(soundId, 1.0f, 1.0f, 1, 0, 1.0f); }
private void startSoundFromSoundPool(int i_Sound, int i_LoopEnabled) { // // checking if the user has enabled the sound and the sound is loaded. if (mSoundEnabled && i_Sound != -1) { mSoundPool.play(i_Sound, 1, 1, 0, i_LoopEnabled, 1); } }
public void button_clicked(Button b) { if (flag == 0) { flag = 1; display.setText("Turn player 2"); b.setBackgroundResource(R.drawable.imagebutton_x); if (sound_for_x != 0) sp_for_x.play(sound_for_x, 1, 1, 0, 0, 1); } else if (flag == 1) { flag = 0; display.setText("Turn player 1"); b.setBackgroundResource(R.drawable.imagebutton_o); if (sound_for_o != 0) sp_for_o.play(sound_for_o, 1, 1, 0, 0, 1); } b.setClickable(false); draw_counter++; }
// Play loaded wav file, loop number of times. public void play_sound_file(int loop) { if (sp != null) { if (currentSound != -1) { currentStreamId = sp.play(currentSound, 0.99f, 0.99f, 1, loop, 1.0f); } ; } }
private void PrimeraPasada() { Log.d(TAG, "ejecutando void PrimeraPasada()"); sonidoCosas.play(sonidoCosasID[contadorPalabras], 1, 1, 1, 0, 1); // Se toca el sonido aHandler.postDelayed( actualizaPantallaP, 1500); // Se llama al handler para hacer los cambios en pantalla (cambiar a la imagen y // modificar el proximo text e image view) }
public void playSound(String sound) { switch (sound) { case "INVALID_MOVE": soundPool.play(invalidMoveID, 1, 1, 0, 0, 1); break; case "MATCH_FOUND": soundPool.play(matchFoundID, 1, 1, 0, 0, 1); break; case "ANGRY": soundPool.play(angryID, 1, 1, 0, 0, 1); break; case "DELIGHTED": soundPool.play(delightedID, 1, 1, 0, 0, 1); break; case "EMBARRASSED": soundPool.play(embarrassedID, 1, 1, 0, 0, 1); break; case "SURPRISED": soundPool.play(surprisedID, 1, 1, 0, 0, 1); break; case "UPSET": soundPool.play(upsetID, 1, 1, 0, 0, 1); break; } }
public void handleMessage(Message msg) { switch (msg.what) { case 1: sp.play(music, 1, 1, 0, 0, 1); updateOrder(); break; } super.handleMessage(msg); }
@Override public long loop(float volume) { if (streamIds.size == 8) streamIds.pop(); int streamId = soundPool.play(soundId, volume, volume, 1, -1, 1); // standardise error code with other backends if (streamId == 0) return -1; streamIds.insert(0, streamId); return streamId; }
@Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (soundId != 0 && status == 0) { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) { int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING); streamId = soundPool.play(soundId, curVolume, curVolume, 1, loop ? -1 : 0, 1f); } } }
public void update() { if (System.currentTimeMillis() - oldTime > FRAMERATEANIMATION) { if (!IsSFXMuted) { soundPool.play(aff, 0, 0, priority, no_loop, normal_playback_rate); } oldTime = (System.currentTimeMillis()); } }
@Override public void onBackPressed() { Log.d(LOG_TAG, "onBackPressed"); soundPool.play(onClick, 1.0F, 1.0F, 0, 0, 1.0F); Intent intent = new Intent(OnGame.this, MainList.class); startActivity(intent); overridePendingTransition(R.anim.in_from_left, R.anim.out_to_right); finish(); }
@Override public void run() { while (playing) { // Capture the current time in milliseconds in startFrameTime long startFrameTime = System.currentTimeMillis(); // Update the frame if (!paused) { update(); } // Draw the frame draw(); // Calculate the fps this frame // We can then use the result to // time animations and more. timeThisFrame = System.currentTimeMillis() - startFrameTime; if (timeThisFrame >= 1) { fps = 1000 / timeThisFrame; } // We will do something new here towards the end of the project // Play a sound based on the menace level if (!paused) { if ((startFrameTime - lastMenaceTime) > menaceInterval) { if (uhOrOh) { // Play Uh soundPool.play(uhID, 1, 1, 0, 0, 1); } else { // Play Oh soundPool.play(ohID, 1, 1, 0, 0, 1); } // Reset the last menace time lastMenaceTime = System.currentTimeMillis(); // Alter value of uhOrOh uhOrOh = !uhOrOh; } } } }
private void PlaySound(Integer ID) { if (!IsSFXMuted) { curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); leftVolume = (curVolume / maxVolume); rightVolume = (curVolume / maxVolume); soundPool.play(ID, leftVolume, rightVolume, priority, no_loop, normal_playback_rate); } }
public void gameOver() { // play a game over sound mSoundPool.play(mGameOverSound, 1, 1, 1, 0, 1); // goto results activity; Intent intent = new Intent(this, ResultsActivity.class); intent.putExtra("score", mScore); startActivity(intent); mGameView.pause(); finish(); }