List of usage examples for android.media AudioAttributes USAGE_GAME
int USAGE_GAME
To view the source code for android.media AudioAttributes USAGE_GAME.
Click Source Link
From source file:com.artioml.practice.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w w w. j a v a 2 s . com ImageButton settingsButton = (ImageButton) findViewById(R.id.settingsButton); settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MainSettingsDialog mainSettingsDialog = new MainSettingsDialog(MainActivity.this); mainSettingsDialog.show(); } }); fillSettingsPanel(); AudioAttributes.Builder attrBuilder = new AudioAttributes.Builder(); attrBuilder.setUsage(AudioAttributes.USAGE_GAME); SoundPool.Builder builder = new SoundPool.Builder(); builder.setMaxStreams(1); builder.setAudioAttributes(attrBuilder.build()); soundPool = builder.build(); soundMap = new SparseIntArray(1); soundMap.put(0, soundPool.load(getBaseContext(), R.raw.fire, 1)); punchButton = (Button) findViewById(R.id.punchButton); punchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { punchButton.setEnabled(false); (new Handler()).postDelayed(new Runnable() { @Override public void run() { soundPool.play(soundMap.get(0), 1, 1, 1, 0, 1f); reaction = 0.00f; maxAcceleration = 0; count = 0; data = new ArrayList<>(); SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(sensorEventListener, sensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION), 1000); } }, 2000); } }); Button historyButton = (Button) findViewById(R.id.historyButton); historyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent historyIntent = new Intent(MainActivity.this, HistoryActivity.class); startActivity(historyIntent); } }); }
From source file:com.kentli.cycletrack.RecordingService.java
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes attributes = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build(); soundpool = new SoundPool.Builder().setAudioAttributes(attributes).build(); } else {/*from w w w. jav a 2 s. c o m*/ soundpool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); } soundpool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { soundPool.play(sampleId, 1.0f, 1.0f, 0, 0, 1.0f); } }); bikebell = soundpool.load(this.getBaseContext(), R.raw.bikebell, 1); }
From source file:ua.com.spasetv.testintuitions.FragExerciseOne.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void createNewSoundPool() { AudioAttributes attributes = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build(); soundPool = new SoundPool.Builder().setAudioAttributes(attributes).build(); }
From source file:com.stillnojetpacks.huffr.activities.MainActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void initializeSoundPool() { if (soundPool != null) { soundPool.release();//from w ww . ja va 2 s. co m } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes audioAttributes = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build(); soundPool = new SoundPool.Builder().setMaxStreams(PREF_SOUNDPOOL_MAX_STREAMS) .setAudioAttributes(audioAttributes).build(); } else { buildBeforeAPI21(); } soundPool.setOnLoadCompleteListener(this); }