List of usage examples for android.media SoundPool SoundPool
public SoundPool(int maxStreams, int streamType, int srcQuality)
From source file:org.peaklabs.consumer.Escanea.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize and start the bar code recognition. initializeAndStartBarcodeScanning(); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(getResources().getString(R.string.scan)); soundpool = new SoundPool(5, AudioManager.STREAM_NOTIFICATION, 0); soundpool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { loaded = true;//w ww . j a va2 s . c o m } }); idBeep = soundpool.load(this, R.raw.beep, 1); }
From source file:com.google.android.apps.santatracker.dasherdancer.DasherDancerActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dasher_dancer); mMeasurement = FirebaseAnalytics.getInstance(this); MeasurementManager.recordScreenView(mMeasurement, getString(R.string.analytics_screen_dasher)); AnalyticsManager.initializeAnalyticsTracker(this); AnalyticsManager.sendScreenView(R.string.analytics_screen_dasher); mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); mMemoryCache = new LruCache<Integer, Bitmap>(240) { protected void entryRemoved(boolean evicted, Integer key, Bitmap oldValue, Bitmap newValue) { if ((oldValue != null) && (oldValue != newValue)) { oldValue.recycle();/*from w w w.ja v a 2 s. co m*/ oldValue = null; } } }; CharacterAdapter adapter = new CharacterAdapter(sCharacters); mPager = (NoSwipeViewPager) findViewById(R.id.character_pager); mPager.setAdapter(adapter); mPager.setGestureDetectorListeners(this, this, this); mPager.setOnPageChangeListener(this); mHandler = new Handler(getMainLooper(), this); mDetector = new ShakeDetector(this); mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); mSoundIds[0][Character.ANIM_PINCH_IN] = mSoundPool.load(this, R.raw.santa_pinchin, 1); mSoundIds[0][Character.ANIM_PINCH_OUT] = mSoundPool.load(this, R.raw.santa_pinchout, 1); mSoundIds[0][Character.ANIM_SHAKE] = mSoundPool.load(this, R.raw.santa_shake, 1); mSoundIds[0][Character.ANIM_SWIPE_UP] = mSoundPool.load(this, R.raw.santa_swipeup, 1); mSoundIds[0][Character.ANIM_SWIPE_LEFT] = mSoundPool.load(this, R.raw.santa_swipeleft, 1); mSoundIds[0][Character.ANIM_SWIPE_RIGHT] = mSoundPool.load(this, R.raw.santa_swiperight, 1); mSoundIds[0][Character.ANIM_SWIPE_DOWN] = mSoundPool.load(this, R.raw.santa_swipedown, 1); mSoundIds[0][Character.ANIM_TAP] = mSoundPool.load(this, R.raw.santa_tap, 1); mSoundIds[1][Character.ANIM_PINCH_IN] = mSoundPool.load(this, R.raw.elf_pinchin_ball, 1); mSoundIds[1][Character.ANIM_PINCH_OUT] = mSoundPool.load(this, R.raw.elf_pinchout, 1); mSoundIds[1][Character.ANIM_SHAKE] = mSoundPool.load(this, R.raw.elf_shake2, 1); mSoundIds[1][Character.ANIM_SWIPE_DOWN] = mSoundPool.load(this, R.raw.elf_swipedown2, 1); mSoundIds[1][Character.ANIM_SWIPE_UP] = mSoundPool.load(this, R.raw.elf_swipeup2, 1); mSoundIds[1][Character.ANIM_SWIPE_LEFT] = mSoundPool.load(this, R.raw.elf_swipeleft, 1); mSoundIds[1][Character.ANIM_SWIPE_RIGHT] = mSoundPool.load(this, R.raw.elf_swiperight, 1); mSoundIds[1][Character.ANIM_TAP] = mSoundPool.load(this, R.raw.elf_tap3, 1); mSoundIds[2][Character.ANIM_PINCH_IN] = mSoundPool.load(this, R.raw.reindeer_pinchin, 1); mSoundIds[2][Character.ANIM_PINCH_OUT] = mSoundPool.load(this, R.raw.reindeer_pinchout, 1); mSoundIds[2][Character.ANIM_SHAKE] = mSoundPool.load(this, R.raw.reindeer_shake, 1); mSoundIds[2][Character.ANIM_SWIPE_UP] = mSoundPool.load(this, R.raw.reindeer_swipeup, 1); mSoundIds[2][Character.ANIM_SWIPE_DOWN] = mSoundPool.load(this, R.raw.reindeer_swipedown, 1); mSoundIds[2][Character.ANIM_SWIPE_LEFT] = mSoundPool.load(this, R.raw.reindeer_swipeleft, 1); mSoundIds[2][Character.ANIM_SWIPE_RIGHT] = mSoundPool.load(this, R.raw.reindeer_swiperight, 1); mSoundIds[2][Character.ANIM_TAP] = mSoundPool.load(this, R.raw.reindeer_tap2, 1); mSoundIds[3][Character.ANIM_PINCH_IN] = mSoundPool.load(this, R.raw.snowman_pinchin, 1); mSoundIds[3][Character.ANIM_PINCH_OUT] = mSoundPool.load(this, R.raw.snowman_pinchout, 1); mSoundIds[3][Character.ANIM_SHAKE] = mSoundPool.load(this, R.raw.snowman_shake, 1); mSoundIds[3][Character.ANIM_SWIPE_UP] = mSoundPool.load(this, R.raw.snowman_swipeup, 1); mSoundIds[3][Character.ANIM_SWIPE_DOWN] = mSoundPool.load(this, R.raw.snowman_swipedown, 1); mSoundIds[3][Character.ANIM_SWIPE_LEFT] = mSoundPool.load(this, R.raw.snowman_swipeleft, 1); mSoundIds[3][Character.ANIM_SWIPE_RIGHT] = mSoundPool.load(this, R.raw.snowman_swiperight, 1); mSoundIds[3][Character.ANIM_TAP] = mSoundPool.load(this, R.raw.snowman_tap, 1); mAchievements = new HashSet[4]; mAchievements[0] = new HashSet<Integer>(); mAchievements[1] = new HashSet<Integer>(); mAchievements[2] = new HashSet<Integer>(); mAchievements[3] = new HashSet<Integer>(); mProgressAnimator = ObjectAnimator.ofFloat(findViewById(R.id.progress), "rotation", 360f); mProgressAnimator.setDuration(4000); mProgressAnimator.start(); mGamesFragment = PlayGamesFragment.getInstance(this, this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ImmersiveModeHelper.setImmersiveSticky(getWindow()); ImmersiveModeHelper.installSystemUiVisibilityChangeListener(getWindow()); } }
From source file:ua.com.spasetv.testintuitions.FragExerciseOne.java
@SuppressWarnings("deprecation") protected void createOldSoundPool() { soundPool = new SoundPool(MAX_STREAM, AudioManager.STREAM_MUSIC, SRC_QUALITY); }
From source file:com.albertcbraun.cms50fw.alert.MainUIFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG, "onCreateView"); View rootView = inflater.inflate(R.layout.fragment_main_activity, container, false); // UI elements messageWindow = (TextView) rootView.findViewById(R.id.message_window); messageWindowScrollView = (ScrollView) rootView.findViewById(R.id.message_window_scroll_view); timeWindow = (TextView) rootView.findViewById(R.id.current_time_window); spo2Window = (TextView) rootView.findViewById(R.id.current_spo2_window); pulseWindow = (TextView) rootView.findViewById(R.id.current_pulse_window); connectButton = (Button) rootView.findViewById(R.id.connect_button); Button startReadingDataButton = (Button) rootView.findViewById(R.id.start_reading_data_button); Button stopReadingDataButton = (Button) rootView.findViewById(R.id.stop_reading_data_button); TextView minimumSpo2PercentageText = (TextView) rootView.findViewById(R.id.minimum_spo2_percentage_text); minimumSpo2PercentageText.addTextChangedListener(new Spo2PercentageTextChangedListener(this)); SeekBar minimumSpo2PercentageSeekBar = (SeekBar) rootView.findViewById(R.id.minimum_spo2_percentage); setUpSeekBar(PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()), minimumSpo2PercentageSeekBar, minimumSpo2PercentageText, minimumSpo2Percentage, MAXIMUM_SPO2_PERCENTAGE_MAX_VALUE_KEY_NAME, MAXIMUM_SPO2_PERCENTAGE_DEFAULT_VALUE, CURRENT_SPO2_PERCENTAGE_MAX_VALUE_KEY_NAME, CURRENT_SPO2_PERCENTAGE_DEFAULT_VALUE); connectButton.setEnabled(true);/*ww w . ja v a2 s .co m*/ startReadingDataButton.setEnabled(false); stopReadingDataButton.setEnabled(false); soundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_ALARM, SRC_QUALITY); // set a custom callback which is fully aware of the main fragment's UI CMS50FWConnectionListener cms50fwCallbacks = new CMS50FWCallbacks(this, connectButton, startReadingDataButton, stopReadingDataButton); this.cms50FWBluetoothConnectionManager.setCMS50FWConnectionListener(cms50fwCallbacks); return rootView; }
From source file:com.greenkee.pokeADot.GameActivity.java
private void loadAudio() { audio = new SoundPool(7, AudioManager.STREAM_MUSIC, 0); bounceSound = audio.load(this, com.greenkee.pokeADot.R.raw.bounce, 1); collectSound = audio.load(this, com.greenkee.pokeADot.R.raw.collect, 1); deathSound = audio.load(this, com.greenkee.pokeADot.R.raw.death, 1); }
From source file:com.honglang.zxing.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow();/*from w ww . j av a 2s . com*/ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); app = (HlApp) getApplication(); title = (TextView) this.findViewById(R.id.title); back = (Button) this.findViewById(R.id.back); back.setOnClickListener(this); // ok = (Button) this.findViewById(R.id.ok); // ok.setText(""); // ok.setVisibility(View.VISIBLE); // ok.setOnClickListener(this); linear = (LinearLayout) findViewById(R.id.out); jf = (LinearLayout) findViewById(R.id.jf); jf.setOnClickListener(this); pc = (LinearLayout) findViewById(R.id.pc); pc.setOnClickListener(this); qsno = (TextView) findViewById(R.id.qsno); jfCount = (TextView) findViewById(R.id.jfCount); jfRecords = (TextView) findViewById(R.id.jfRecords); jfCode = (TextView) findViewById(R.id.jfCode); pcno = (TextView) findViewById(R.id.pcno); pcCount = (TextView) findViewById(R.id.pcCount); pcRecords = (TextView) findViewById(R.id.pcRecords); pcCode = (TextView) findViewById(R.id.pcCode); count = (TextView) findViewById(R.id.count); record = (TextView) findViewById(R.id.record); sure = (Button) findViewById(R.id.sure); sure.setOnClickListener(this); soundPool = new SoundPool(4, AudioManager.STREAM_SYSTEM, 5); soundPool.load(this, R.raw.success, 1); soundPool.load(this, R.raw.done, 1); soundPool.load(this, R.raw.both, 1); soundPool.load(this, R.raw.failed, 1); TYPE = this.getIntent().getExtras().getInt("QRTYPE"); switch (TYPE) { case 0: title.setText("???"); break; case 1: title.setText("???"); break; case 2: title.setText("????"); break; case 3: title.setText("????"); break; case 4: title.setText("??"); break; case 5: title.setText("???"); break; case 6: title.setText(""); linear.setVisibility(View.VISIBLE); new NewTask().execute((Void) null); break; } hasSurface = false; historyManager = new HistoryManager(this); historyManager.trimHistory(); inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); ambientLightManager = new AmbientLightManager(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); }
From source file:com.stillnojetpacks.huffr.activities.MainActivity.java
@SuppressWarnings("deprecation") private void buildBeforeAPI21() { soundPool = new SoundPool(PREF_SOUNDPOOL_MAX_STREAMS, AudioManager.STREAM_MUSIC, 0); }
From source file:com.google.android.apps.santatracker.games.matching.MemoryMatchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_memory_match, container, false); rootView.setKeepScreenOn(true);/*from www . j a va 2 s . c om*/ // Below ICS, display a special, simplified background for the entire fragment if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { rootView.findViewById(R.id.match_score_layout) .setBackgroundResource(R.drawable.score_background_gingerbread); } // Initialise the sound pool and all sound effects mSoundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); mSoundDoorOpen = mSoundPool.load(getActivity(), R.raw.mmg_open_door_3, 1); mSoundDoorClose = mSoundPool.load(getActivity(), R.raw.mmg_close_door, 1); mSoundMatchWrong = mSoundPool.load(getActivity(), R.raw.mmg_wrong, 1); mSoundMatchRight = mSoundPool.load(getActivity(), R.raw.mmg_right, 1); mSoundGameOver = mSoundPool.load(getActivity(), R.raw.gameover, 1); mSoundBeep = mSoundPool.load(getActivity(), R.raw.mmg_open_door_2, 1); // Set up all animations. loadAnimations(); // G+ sign-in views mViewGPlusSignIn = (ImageView) rootView.findViewById(R.id.gplus_button); mViewGPlusSignIn.setOnClickListener(this); mLayoutGPlus = rootView.findViewById(R.id.play_again_gplus); mLayoutGPlus.setVisibility(View.GONE); // 'Play again' screen views mTextPlayAgainScore = (TextView) rootView.findViewById(R.id.play_again_score); mTextPlayAgainScore.setText(String.valueOf(mMatchScore)); mTextPlayAgainLevel = (TextView) rootView.findViewById(R.id.play_again_level); mTextPlayAgainLevel.setText(String.valueOf(mLevelNumber)); mViewPlayAgainBackground = rootView.findViewById(R.id.play_again_bkgrd); mViewPlayAgainMain = rootView.findViewById(R.id.play_again_main); mPlayAgainBtn = (Button) rootView.findViewById(R.id.play_again_btn); mPlayAgainBtn.setOnClickListener(this); // Level, countdown and score views at the bottom of the screen mTimerTextView = (TextView) rootView.findViewById(R.id.match_timer); mLevelNumberText = (LevelTextView) rootView.findViewById(R.id.card_end_level_number); mLevelNumberText.setVisibility(View.GONE); mScoreText = (TextView) rootView.findViewById(R.id.match_score); mScoreText.setText(String.valueOf(mMatchScore)); // End of level animated circle mEndLevelCircle = (CircleView) rootView.findViewById(R.id.card_end_level_circle); mEndLevelCircle.setVisibility(View.GONE); // The snowman that is animated as a bonus when the player is particularly awesome mViewBonusSnowman = rootView.findViewById(R.id.match_snowman); // 'Pause' screen views mButtonMenu = (ImageButton) rootView.findViewById(R.id.main_menu_button); mButtonMenu.setOnClickListener(this); mButtonMenu.setVisibility(View.GONE); mButtonPlay = (ImageView) rootView.findViewById(R.id.match_play_button); mButtonPlay.setOnClickListener(this); mButtonPlay.setVisibility(View.GONE); mButtonPause = (ImageView) rootView.findViewById(R.id.match_pause_button); mButtonPause.setOnClickListener(this); mButtonPause.setVisibility(View.VISIBLE); mViewPauseOverlay = rootView.findViewById(R.id.match_pause_overlay); mViewPauseOverlay.setVisibility(View.GONE); mButtonBigPlay = (ImageButton) rootView.findViewById(R.id.match_big_play_button); mButtonBigPlay.setOnClickListener(this); mButtonCancelBar = (ImageButton) rootView.findViewById(R.id.match_cancel_bar); mButtonCancelBar.setOnClickListener(this); mButtonCancelBar.setVisibility(View.GONE); // Playing cards (doors) mViewCard[0] = rootView.findViewById(R.id.card_position_1); mViewCard[1] = rootView.findViewById(R.id.card_position_2); mViewCard[2] = rootView.findViewById(R.id.card_position_3); mViewCard[3] = rootView.findViewById(R.id.card_position_4); mViewCard[4] = rootView.findViewById(R.id.card_position_5); mViewCard[5] = rootView.findViewById(R.id.card_position_6); mViewCard[6] = rootView.findViewById(R.id.card_position_7); mViewCard[7] = rootView.findViewById(R.id.card_position_8); mViewCard[8] = rootView.findViewById(R.id.card_position_9); mViewCard[9] = rootView.findViewById(R.id.card_position_10); mViewCard[10] = rootView.findViewById(R.id.card_position_11); mViewCard[11] = rootView.findViewById(R.id.card_position_12); // Display the instructions if they haven't been seen by the player yet. mPreferences = getActivity().getSharedPreferences(MatchingGameConstants.PREFERENCES_FILENAME, Context.MODE_PRIVATE); if (!mPreferences.getBoolean(MatchingGameConstants.MATCH_INSTRUCTIONS_VIEWED, false)) { // Instructions haven't been viewed yet. Construct an AnimationDrawable with instructions. mInstructionDrawable = new AnimationDrawable(); mInstructionDrawable.addFrame(getResources().getDrawable(R.drawable.instructions_touch_1), 300); mInstructionDrawable.addFrame(getResources().getDrawable(R.drawable.instructions_touch_2), 300); mInstructionDrawable.setOneShot(false); mViewInstructions = (ImageView) rootView.findViewById(R.id.instructions); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mViewInstructions.setImageResource(R.drawable.instructions_touch_1); } else { mViewInstructions.setImageDrawable(mInstructionDrawable); mInstructionDrawable.start(); } // Set a timer to hide the instructions after 2 seconds mViewInstructions.postDelayed(new StartGameDelay(), 2000); } else { //Instructions have already been viewed. Start the first level. setUpLevel(); } return rootView; }
From source file:org.cocos2dx.lib.Cocos2dxSound.java
private void initData() { this.mPathStreamIDsMap = new HashMap<String, ArrayList<Integer>>(); this.mPathSoundIdMap = new HashMap<String, Integer>(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; }
From source file:com.ayaseya.padnotification.GcmIntentService.java
@Override protected void onHandleIntent(final Intent intent) { extras = intent.getExtras();/*from w ww .j av a2 s . c o m*/ GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); // displayMessage(this, extras.toString()); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { // sendNotification("Send error: " + extras.toString()); Log.v(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // sendNotification("Deleted messages on server: " + extras.toString()); Log.v(TAG, "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. // ?????IntentService???????? // ????????? new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { // Log.v(TAG, "doInBackground()"); // soundPool????? soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0); // soundPool??Listener?????? soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { @Override public void onLoadComplete(final SoundPool soundPool, int sampleId, int status) { if (status == 0) { if (notificationPermission) {// ???????? // Notification???? sendNotification("??????" + extras.get("INDEX") + "??", intent); //?????????? if (isPlugged) {// ??????? Log.v(TAG, "??????"); if (ringerMode) {// Log.v(TAG, ""); if (checkbox_sound) { soundPool.play(se, 0.5F, 0.5F, 0, 0, 1.0F); } if (checkbox_vibration) { vibrator.vibrate(1500); } } else if (vibrateMode) {// Log.v(TAG, ""); if (checkbox_vibration) { vibrator.vibrate(1500); } } else if (silentMode) {// Log.v(TAG, ""); if (checkbox_sound) { soundPool.play(se, 0.5F, 0.5F, 0, 0, 1.0F); } } } else {// ????????? Log.v(TAG, "??????"); if (ringerMode) {// Log.v(TAG, ""); if (checkbox_sound) { soundPool.play(se, 0.5F, 0.5F, 0, 0, 1.0F); } if (checkbox_vibration) { vibrator.vibrate(1500); } } else if (vibrateMode) {// Log.v(TAG, ""); if (checkbox_vibration) { vibrator.vibrate(1500); } } else if (silentMode) {// Log.v(TAG, ""); } } } // ?soundPool???? new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(30000); } catch (InterruptedException e) { } // Log.v(TAG, "soundPool.release()"); soundPool.release(); } }).start(); } } }); // soundPool????? se = soundPool.load(GcmIntentService.this, R.raw.notification_sound, 1); return null; } }.execute(null, null, null); // sendNotification("??????" + extras.get("INDEX") + "???", intent); // sendNotification("Received: " + extras.toString()); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }