本文整理汇总了Java中android.media.AudioManager.playSoundEffect方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.playSoundEffect方法的具体用法?Java AudioManager.playSoundEffect怎么用?Java AudioManager.playSoundEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.playSoundEffect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playClick
import android.media.AudioManager; //导入方法依赖的package包/类
private void playClick(int keyCode) {
AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 0x20:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
case 0x0a:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
case 0x38:
if (prefs.getBoolean("pref_eight_enable", false)) {
// Play random "eight" sound
MediaPlayer mPlayer = mediaEight[rand.nextInt(mediaEight.length)];
mPlayer.seekTo(0);
mPlayer.start();
}
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
}
}
示例2: playclick
import android.media.AudioManager; //导入方法依赖的package包/类
private void playclick(int keyCode){
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 32:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case 10:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
break;
}
}
示例3: onHandleIntent
import android.media.AudioManager; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
// Play a click sound and vibrate quickly
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
AudioManager audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
audioManager.playSoundEffect(SoundEffectConstants.CLICK, 1.0f);
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATOR_PULSE);
try {
Bundle data = new Bundle();
data.putString("user",
sharedPreferences.getString(GarageDoorWidgetProvider.PREF_USERNAME, ""));
data.putString("password",
sharedPreferences.getString(GarageDoorWidgetProvider.PREF_PASSWORD, ""));
data.putString("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
String id = Integer.toString(getNextMsgId());
gcm.send(GarageDoorWidgetProvider.GCM_SENDER_ID + "@gcm.googleapis.com",
id, TIME_TO_LIVE, data);
} catch (IOException e) {
Log.e(TAG, "Error sending message", e);
}
}
示例4: playClick
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* Play sound on key press
*
* @param keyCode of pressed key
*/
private void playClick(int keyCode) {
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case Constants.KeyCode.SPACE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Constants.KeyCode.RETURN:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
break;
}
}
示例5: playClick
import android.media.AudioManager; //导入方法依赖的package包/类
private void playClick(int keyCode) {
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 32:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
case 10:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
}
}
示例6: onKeyUpPanel
import android.media.AudioManager; //导入方法依赖的package包/类
private boolean onKeyUpPanel(int featureId, KeyEvent event) {
if (this.mActionMode != null) {
return false;
}
boolean handled = false;
PanelFeatureState st = getPanelState(featureId, true);
if (featureId != 0 || this.mDecorContentParent == null || !this.mDecorContentParent.canShowOverflowMenu() || ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(this.mContext))) {
if (st.isOpen || st.isHandled) {
handled = st.isOpen;
closePanel(st, true);
} else if (st.isPrepared) {
boolean show = true;
if (st.refreshMenuContent) {
st.isPrepared = false;
show = preparePanel(st, event);
}
if (show) {
openPanel(st, event);
handled = true;
}
}
} else if (this.mDecorContentParent.isOverflowMenuShowing()) {
handled = this.mDecorContentParent.hideOverflowMenu();
} else if (!isDestroyed() && preparePanel(st, event)) {
handled = this.mDecorContentParent.showOverflowMenu();
}
if (!handled) {
return handled;
}
AudioManager audioManager = (AudioManager) this.mContext.getSystemService("audio");
if (audioManager != null) {
audioManager.playSoundEffect(0);
return handled;
}
Log.w("AppCompatDelegate", "Couldn't get audio manager");
return handled;
}