当前位置: 首页>>代码示例>>Java>>正文


Java AudioManager.playSoundEffect方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:rollforbugs,项目名称:lokey,代码行数:26,代码来源:IME.java

示例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;
    }
}
 
开发者ID:zhaofengli,项目名称:airboard,代码行数:18,代码来源:AirBoard.java

示例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);
    }
}
 
开发者ID:jpuderer,项目名称:GarageDoor,代码行数:27,代码来源:GarageDoorIntentService.java

示例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;
    }
}
 
开发者ID:Medeuz,项目名称:CustomAndroidKeyboard,代码行数:26,代码来源:SimpleIME.java

示例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);
    }
}
 
开发者ID:YehtutHl,项目名称:myan,代码行数:18,代码来源:SmartMyan.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:38,代码来源:AppCompatDelegateImplV7.java


注:本文中的android.media.AudioManager.playSoundEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。