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); }
public GoSoundManager(GobandroidFragmentActivity theContext) { Log.i("sound_man init"); mContext = theContext; mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); mSoundPoolMap = new HashMap<>(); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); addSound(SOUND_START, R.raw.go_start); addSound(SOUND_END, R.raw.go_clearboard); addSound(SOUND_PLACE1, R.raw.go_place1); addSound(SOUND_PLACE2, R.raw.go_place2); addSound(SOUND_PICKUP1, R.raw.go_pickup1); addSound(SOUND_PICKUP2, R.raw.go_pickup2); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GoPrefs.init(this); progress = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); progress.setMax(100); progress.setProgress(10); LinearLayout lin = new LinearLayout(this); ImageView img = new ImageView(this); img.setImageResource(R.drawable.ic_launcher); img.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lin.setOrientation(LinearLayout.VERTICAL); lin.addView(img); FrameLayout frame = new FrameLayout(this); frame.addView(progress); message_tv = new TextView(this); message_tv.setText("starting"); message_tv.setTextColor(0xFF000000); message_tv.setPadding(7, 0, 0, 0); frame.addView(message_tv); lin.addView(frame); alert_dlg = new AlertDialog.Builder(this) .setCancelable(false) .setTitle(R.string.loading_sgf) .setView(lin) .show(); EasyTracker.getTracker() .trackEvent("ui_action", "load_sgf", getIntent().getData().toString(), null); new Thread(this).start(); }
@Override public void onResume() { super.onResume(); }