本文整理汇总了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);
}