Changeset 2fc778c in orbit for android/src
- Timestamp:
- 11/29/12 15:14:32 (10 years ago)
- Branches:
- master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
- Children:
- f323fb4
- Parents:
- 754dbda
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
android/src/info/puzzlebox/orbit/MainActivity.java
r0401409 r2fc778c 13 13 import android.media.AudioManager; 14 14 import android.media.AudioTrack; 15 import android.media.SoundPool; 16 import android.media.SoundPool.OnLoadCompleteListener; 15 17 import android.os.Bundle; 16 18 import android.os.Handler; … … 25 27 import android.graphics.drawable.shapes.RoundRectShape; 26 28 import android.hardware.usb.UsbManager; 29 import android.util.Log; 27 30 import android.view.Gravity; 28 31 //import android.view.Menu; … … 96 99 97 100 101 // 2012.11.28-orbit-hdmi-android-manual_from_untitled08.wav 102 private SoundPool soundPool; 103 private int soundID; 104 boolean loaded = false; 105 98 106 // Tone Generator 99 107 // http://stackoverflow.com/questions/2413426/playing-an-arbitrary-tone-with-android … … 261 269 genTone(); 262 270 //playSound(); 271 272 273 // Set the hardware buttons to control the music 274 this.setVolumeControlStream(AudioManager.STREAM_MUSIC); 275 // Load the sound 276 soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); 277 soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { 278 // @Override 279 public void onLoadComplete(SoundPool soundPool, int sampleId, 280 int status) { 281 loaded = true; 282 } 283 }); 284 soundID = soundPool.load(this, R.raw.htc_one_x, 1); 263 285 264 286 … … 575 597 public void demoMode(View view) { 576 598 577 playSound(); 599 // playSound(); 600 601 602 // Getting the user sound settings 603 AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); 604 float actualVolume = (float) audioManager 605 .getStreamVolume(AudioManager.STREAM_MUSIC); 606 float maxVolume = (float) audioManager 607 .getStreamMaxVolume(AudioManager.STREAM_MUSIC); 608 float volume = actualVolume / maxVolume; 609 // Is the sound loaded already? 610 if (loaded) { 611 soundPool.play(soundID, volume, volume, 1, 0, 1f); 612 Log.e("Test", "Played sound"); 613 } 614 578 615 579 616 // String command = "neutral";
Note: See TracChangeset
for help on using the changeset viewer.