Search in sources :

Example 46 with AudioManager

use of android.media.AudioManager in project QRCode by 5peak2me.

the class CaptureActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;
    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;
}
Also used : SurfaceHolder(android.view.SurfaceHolder) AudioManager(android.media.AudioManager) SurfaceView(android.view.SurfaceView)

Example 47 with AudioManager

use of android.media.AudioManager in project SeaStar by 13120241790.

the class SettingActivity method onCheckedChanged.

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch(buttonView.getId()) {
        case R.id.show_desktopkf:
            if (isChecked) {
                BroadcastManager.getInstance(mContext).sendBroadcast(START);
                edit.putBoolean(DESKTOP, true);
                edit.commit();
            } else {
                BroadcastManager.getInstance(mContext).sendBroadcast(CLOSE);
                edit.putBoolean(DESKTOP, false);
                edit.commit();
            }
            break;
        case R.id.seting_voice:
            AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
            if (isChecked) {
                audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
                edit.putBoolean(VOICE, true);
                edit.commit();
            } else {
                audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
                edit.putBoolean(VOICE, false);
                edit.commit();
            }
            break;
        case R.id.setting_push:
            if (isChecked) {
                BroadcastManager.getInstance(mContext).sendBroadcast(PUSHSTART);
                edit.putBoolean(PUSH, true);
                edit.commit();
            } else {
                BroadcastManager.getInstance(mContext).sendBroadcast(PUSHCLOSE);
                edit.putBoolean(PUSH, false);
                edit.commit();
            }
            break;
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 48 with AudioManager

use of android.media.AudioManager in project android_frameworks_base by DirtyUnicorns.

the class VideoView method stopPlayback.

public void stopPlayback() {
    if (mMediaPlayer != null) {
        mMediaPlayer.stop();
        mMediaPlayer.release();
        mMediaPlayer = null;
        mCurrentState = STATE_IDLE;
        mTargetState = STATE_IDLE;
        AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        am.abandonAudioFocus(null);
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 49 with AudioManager

use of android.media.AudioManager in project android_frameworks_base by DirtyUnicorns.

the class VideoView method release.

/*
     * release the media player in any state
     */
private void release(boolean cleartargetstate) {
    if (mMediaPlayer != null) {
        mMediaPlayer.reset();
        mMediaPlayer.release();
        mMediaPlayer = null;
        mPendingSubtitleTracks.clear();
        mCurrentState = STATE_IDLE;
        if (cleartargetstate) {
            mTargetState = STATE_IDLE;
        }
        AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        am.abandonAudioFocus(null);
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 50 with AudioManager

use of android.media.AudioManager in project android_frameworks_base by DirtyUnicorns.

the class BluetoothTestUtils method startStopSco.

/**
     * Helper method for {@link #startSco(BluetoothAdapter, BluetoothDevice)} and
     * {@link #stopSco(BluetoothAdapter, BluetoothDevice)}.
     *
     * @param adapter The BT adapter.
     * @param device The remote device.
     * @param isStart Whether the SCO channel should be opened.
     */
private void startStopSco(BluetoothAdapter adapter, BluetoothDevice device, boolean isStart) {
    long start = -1;
    int mask;
    String methodName;
    if (isStart) {
        methodName = String.format("startSco(device=%s)", device);
        mask = StartStopScoReceiver.STATE_CONNECTED_FLAG;
    } else {
        methodName = String.format("stopSco(device=%s)", device);
        mask = StartStopScoReceiver.STATE_DISCONNECTED_FLAG;
    }
    if (!adapter.isEnabled()) {
        fail(String.format("%s bluetooth not enabled", methodName));
    }
    if (!adapter.getBondedDevices().contains(device)) {
        fail(String.format("%s device not paired", methodName));
    }
    AudioManager manager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    assertNotNull(manager);
    if (!manager.isBluetoothScoAvailableOffCall()) {
        fail(String.format("%s device does not support SCO", methodName));
    }
    boolean isScoOn = manager.isBluetoothScoOn();
    if (isStart == isScoOn) {
        return;
    }
    StartStopScoReceiver receiver = getStartStopScoReceiver(mask);
    start = System.currentTimeMillis();
    if (isStart) {
        manager.startBluetoothSco();
    } else {
        manager.stopBluetoothSco();
    }
    long s = System.currentTimeMillis();
    while (System.currentTimeMillis() - s < START_STOP_SCO_TIMEOUT) {
        isScoOn = manager.isBluetoothScoOn();
        if (isStart == isScoOn && (receiver.getFiredFlags() & mask) == mask) {
            long finish = receiver.getCompletedTime();
            if (start != -1 && finish != -1) {
                writeOutput(String.format("%s completed in %d ms", methodName, (finish - start)));
            } else {
                writeOutput(String.format("%s completed", methodName));
            }
            removeReceiver(receiver);
            return;
        }
        sleep(POLL_TIME);
    }
    int firedFlags = receiver.getFiredFlags();
    removeReceiver(receiver);
    fail(String.format("%s timeout: on=%b (expected %b), flags=0x%x (expected 0x%x)", methodName, isScoOn, isStart, firedFlags, mask));
}
Also used : AudioManager(android.media.AudioManager)

Aggregations

AudioManager (android.media.AudioManager)159 MediaPlayer (android.media.MediaPlayer)50 AudioEffect (android.media.audiofx.AudioEffect)42 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 Context (android.content.Context)9 Intent (android.content.Intent)7 IOException (java.io.IOException)7 Cea708CaptionRenderer (android.media.Cea708CaptionRenderer)5 ClosedCaptionRenderer (android.media.ClosedCaptionRenderer)5 MediaFormat (android.media.MediaFormat)5 Ringtone (android.media.Ringtone)5 SubtitleController (android.media.SubtitleController)5 TtmlRenderer (android.media.TtmlRenderer)5 WebVttRenderer (android.media.WebVttRenderer)5 PowerManager (android.os.PowerManager)5 InputStream (java.io.InputStream)5 View (android.view.View)4 NotificationManager (android.app.NotificationManager)3 PendingIntent (android.app.PendingIntent)3