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 JieCaoVideoPlayer by lipangit.
the class JCVideoPlayer method prepareMediaPlayer.
public void prepareMediaPlayer() {
JCVideoPlayerManager.completeAll();
Log.d(TAG, "prepareMediaPlayer [" + this.hashCode() + "] ");
initTextureView();
addTextureView();
AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManager.requestAudioFocus(onAudioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
JCUtils.scanForActivity(getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
JCMediaManager.CURRENT_PLAYING_URL = url;
JCMediaManager.CURRENT_PLING_LOOP = loop;
JCMediaManager.MAP_HEADER_DATA = headData;
setUiWitStateAndScreen(CURRENT_STATE_PREPARING);
JCVideoPlayerManager.setFirstFloor(this);
}
use of android.media.AudioManager in project JieCaoVideoPlayer by lipangit.
the class JCVideoPlayer method onCompletion.
public void onCompletion() {
Log.i(TAG, "onCompletion " + " [" + this.hashCode() + "] ");
//save position
if (currentState == CURRENT_STATE_PLAYING || currentState == CURRENT_STATE_PAUSE) {
int position = getCurrentPositionWhenPlaying();
// int duration = getDuration();
JCUtils.saveProgress(getContext(), url, position);
}
cancelProgressTimer();
setUiWitStateAndScreen(CURRENT_STATE_NORMAL);
// 清理缓存变量
textureViewContainer.removeView(JCMediaManager.textureView);
JCMediaManager.instance().currentVideoWidth = 0;
JCMediaManager.instance().currentVideoHeight = 0;
AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
JCUtils.scanForActivity(getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
clearFullscreenLayout();
JCUtils.getAppCompActivity(getContext()).setRequestedOrientation(NORMAL_ORIENTATION);
JCMediaManager.textureView = null;
JCMediaManager.savedSurfaceTexture = null;
}
use of android.media.AudioManager in project PLDroidPlayer by pili-engineering.
the class PLMediaPlayerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_media_player);
mLoadingView = findViewById(R.id.LoadingView);
mSurfaceView = (SurfaceView) findViewById(R.id.SurfaceView);
mSurfaceView.getHolder().addCallback(mCallback);
mVideoPath = getIntent().getStringExtra("videoPath");
mAVOptions = new AVOptions();
int isLiveStreaming = getIntent().getIntExtra("liveStreaming", 1);
// the unit of timeout is ms
mAVOptions.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
mAVOptions.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
mAVOptions.setInteger(AVOptions.KEY_PROBESIZE, 128 * 1024);
// Some optimization with buffering mechanism when be set to 1
mAVOptions.setInteger(AVOptions.KEY_LIVE_STREAMING, isLiveStreaming);
mIsLiveStreaming = isLiveStreaming == 1;
if (mIsLiveStreaming) {
mAVOptions.setInteger(AVOptions.KEY_DELAY_OPTIMIZATION, 1);
}
// 1 -> hw codec enable, 0 -> disable [recommended]
int iCodec = getIntent().getIntExtra("mediaCodec", AVOptions.MEDIA_CODEC_SW_DECODE);
mAVOptions.setInteger(AVOptions.KEY_MEDIACODEC, iCodec);
// whether start play automatically after prepared, default value is 1
mAVOptions.setInteger(AVOptions.KEY_START_ON_PREPARED, 0);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
}
use of android.media.AudioManager in project PLDroidPlayer by pili-engineering.
the class PLMediaPlayerActivity method onDestroy.
@Override
protected void onDestroy() {
super.onDestroy();
release();
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.abandonAudioFocus(null);
}
Aggregations