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);
}
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;
}
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;
}
}
}
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);
}
}
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);
}
}
Aggregations