本文整理匯總了Java中android.media.SoundPool.play方法的典型用法代碼示例。如果您正苦於以下問題:Java SoundPool.play方法的具體用法?Java SoundPool.play怎麽用?Java SoundPool.play使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.SoundPool
的用法示例。
在下文中一共展示了SoundPool.play方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: play
import android.media.SoundPool; //導入方法依賴的package包/類
public void play(SoundPool engineSound) {
long currentTime = System.currentTimeMillis();
if (currentTime - mLastPlayTime > FLOOD_TIMEOUT) {
mLastPlayTime = currentTime;
int posToPlay = sRandom.nextInt(mSoundId.length);
engineSound.play(mSoundId[posToPlay], 1.0f, 1.0f, 0, 0, 1.0f);
}
}
示例2: doAlarm
import android.media.SoundPool; //導入方法依賴的package包/類
private void doAlarm() {
if (mCurrMInfo.isVibrate()){
mVibrator.vibrate(1000);
}
if (mCurrMInfo.isRing()){
SoundPool soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 5);
soundPool.load(this, R.raw.ticket_alarm, 1);
soundPool.play(1, 1, 1, 0, 0, 1);
}
}
示例3: doAudioAlert
import android.media.SoundPool; //導入方法依賴的package包/類
public void doAudioAlert(Context context) {
// Use a throttler to keep this from interrupting itself too much.
if (SystemClock.elapsedRealtime() - mLastAudioMs < THROTTLE_LIMIT_MS) {
return;
}
SoundPool soundPool = getSoundPool(context);
if (sSoundId != -1) {
mLastAudioMs = SystemClock.elapsedRealtime();
soundPool.play(sSoundId, .8f, .8f, 0, 0, 1.0f);
}
}
示例4: play
import android.media.SoundPool; //導入方法依賴的package包/類
private static void play(SoundPool soundPool, int soundId) {
AudioManager audioManager = (AudioManager) MikuApplication.context
.getSystemService(Context.AUDIO_SERVICE);
float actualVolume = (float) audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = (float) audioManager
.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
final float audioCurrentVolume = actualVolume / maxVolume;
soundPool.play(soundId, audioCurrentVolume, audioCurrentVolume, 0, 0, 1);
}
示例5: onLoadComplete
import android.media.SoundPool; //導入方法依賴的package包/類
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
soundPool.play(soundid, volumnRatio, volumnRatio, 1, playCount, 1);
// 左右聲道 為 1 優先級為 1 循環三次 ,速度正常 (小於1放慢 大於1放快 最大為2)
}
示例6: onLoadComplete
import android.media.SoundPool; //導入方法依賴的package包/類
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
soundPool.play(sampleId, 0.99f, 0.99f, 1, 0, 1);
}
示例7: onShutter
import android.media.SoundPool; //導入方法依賴的package包/類
@Override
public void onShutter() {
SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
int shutterSound = soundPool.load(PhotoFaceCaptureActivity.this, R.raw.camera_shutter_click, 0);
soundPool.play(shutterSound, 1f, 1f, 0, 0, 1);
}