Search in sources :

Example 26 with AudioManager

use of android.media.AudioManager in project gdk-apidemo-sample by googleglass.

the class SliderActivity method onCreate.

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    // Ensure screen stays on during demo.
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mCardScroller = new CardScrollView(this);
    mCardScroller.setAdapter(new CardAdapter(createCards(this)));
    mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Plays sound.
            AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            am.playSoundEffect(Sounds.TAP);
            processSliderRequest(position);
        }
    });
    setContentView(mCardScroller);
    mSlider = Slider.from(mCardScroller);
}
Also used : AudioManager(android.media.AudioManager) CardScrollView(com.google.android.glass.widget.CardScrollView) AdapterView(android.widget.AdapterView) CardAdapter(com.google.android.glass.sample.apidemo.card.CardAdapter) CardScrollView(com.google.android.glass.widget.CardScrollView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 27 with AudioManager

use of android.media.AudioManager in project android-zxingLibrary by yipianfengye.

the class CaptureFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;
    playBeep = true;
    AudioManager audioService = (AudioManager) getActivity().getSystemService(getActivity().AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;
}
Also used : AudioManager(android.media.AudioManager)

Example 28 with AudioManager

use of android.media.AudioManager in project XobotOS by xamarin.

the class HTML5Audio method play.

private void play() {
    if ((mState >= ERROR && mState < PREPARED) && mUrl != null) {
        resetMediaPlayer();
        setDataSource(mUrl);
        mAskToPlay = true;
    }
    if (mState >= PREPARED) {
        AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        int result = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
        if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
            mMediaPlayer.start();
            mState = STARTED;
        }
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 29 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 30 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)

Aggregations

AudioManager (android.media.AudioManager)157 MediaPlayer (android.media.MediaPlayer)49 AudioEffect (android.media.audiofx.AudioEffect)42 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 Context (android.content.Context)8 IOException (java.io.IOException)7 Intent (android.content.Intent)6 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 InputStream (java.io.InputStream)5 PowerManager (android.os.PowerManager)4 Vibrator (android.os.Vibrator)4 SurfaceHolder (android.view.SurfaceHolder)4 SurfaceView (android.view.SurfaceView)4