本文整理汇总了Java中android.media.AudioManager.abandonAudioFocus方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.abandonAudioFocus方法的具体用法?Java AudioManager.abandonAudioFocus怎么用?Java AudioManager.abandonAudioFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.abandonAudioFocus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import android.media.AudioManager; //导入方法依赖的package包/类
public void stop(boolean playDisconnected) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
incomingRinger.stop();
outgoingRinger.stop();
if (playDisconnected) {
soundPool.play(disconnectedSoundId, 1.0f, 1.0f, 0, 0, 1.0f);
}
if (audioManager.isBluetoothScoOn()) {
audioManager.setBluetoothScoOn(false);
audioManager.stopBluetoothSco();
}
audioManager.setSpeakerphoneOn(false);
audioManager.setMicrophoneMute(false);
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.abandonAudioFocus(null);
}
示例2: release
import android.media.AudioManager; //导入方法依赖的package包/类
public void release(boolean cleartargetstate) {
if (mMediaPlayer != null) {
mMediaPlayer.reset();
mMediaPlayer.release();
mMediaPlayer = null;
mCurrentState = STATE_IDLE;
if (cleartargetstate) {
mTargetState = STATE_IDLE;
}
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
if (am != null) {
am.abandonAudioFocus(null);
}
}
}
示例3: onCompletion
import android.media.AudioManager; //导入方法依赖的package包/类
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();
ListVideoUtils.saveProgress(getContext(), url, position);
}
onStateAction(CURRENT_STATE_NORMAL);
// 清理缓存变量
textureViewContainer.removeView(MediaManager.textureView);
MediaManager.instance().currentVideoWidth = 0;
MediaManager.instance().currentVideoHeight = 0;
AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
ListVideoUtils.scanForActivity(getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
clearFullscreenLayout();
ListVideoUtils.getActivity(getContext()).setRequestedOrientation(NORMAL_ORIENTATION);
MediaManager.textureView = null;
MediaManager.savedSurfaceTexture = null;
// MediaManager.textureView = null;
}
示例4: onCompletion
import android.media.AudioManager; //导入方法依赖的package包/类
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();
onStateNormal();
// 清理缓存变量
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;
}
示例5: onCompletion
import android.media.AudioManager; //导入方法依赖的package包/类
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);
}
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;
// JCMediaManager.textureView = null;
}
示例6: release
import android.media.AudioManager; //导入方法依赖的package包/类
public void release(boolean cleartargetstate) {
if (mMediaPlayer != null) {
mMediaPlayer.reset();
mMediaPlayer.release();
mMediaPlayer = null;
// REMOVED: mPendingSubtitleTracks.clear();
mCurrentState = STATE_IDLE;
if (cleartargetstate) {
mTargetState = STATE_IDLE;
}
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
示例7: stopPlayback
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* 停止播放
*/
public void stopPlayback() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
mCurrentState = MediaPlayerParams.STATE_IDLE;
mTargetState = MediaPlayerParams.STATE_IDLE;
_notifyMediaStatus();
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
示例8: release
import android.media.AudioManager; //导入方法依赖的package包/类
public void release(boolean cleartargetstate) {
if (mMediaPlayer != null) {
mMediaPlayer.reset();
mMediaPlayer.release();
mMediaPlayer = null;
// REMOVED: mPendingSubtitleTracks.clear();
mCurrentState = MediaPlayerParams.STATE_IDLE;
_notifyMediaStatus();
if (cleartargetstate) {
mTargetState = MediaPlayerParams.STATE_IDLE;
}
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
示例9: release
import android.media.AudioManager; //导入方法依赖的package包/类
public void release() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
}
if (mSurfaceView.getHolder() != null) {
mSurfaceView.getHolder().removeCallback(mCallback);
}
AudioManager audioManager = (AudioManager) App.getAppContext().getSystemService(Context.AUDIO_SERVICE);
audioManager.abandonAudioFocus(null);
}
示例10: stopPlayback
import android.media.AudioManager; //导入方法依赖的package包/类
public void stopPlayback() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
示例11: stopPlayback
import android.media.AudioManager; //导入方法依赖的package包/类
public void stopPlayback() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
if (mHudViewHolder != null)
mHudViewHolder.setMediaPlayer(null);
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
示例12: stopPlayback
import android.media.AudioManager; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.FROYO)
public void stopPlayback() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
if (mHudViewHolder != null)
mHudViewHolder.setMediaPlayer(null);
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
示例13: abandonAudioFocus
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* 释放音频焦点
*/
public static void abandonAudioFocus(Context context) {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.abandonAudioFocus(null);//放弃焦点
}
示例14: onAudioFocusChange
import android.media.AudioManager; //导入方法依赖的package包/类
public void onAudioFocusChange(int focusChange) {
Log.d("onAudioFocusChange " + focusChange);
AudioManager am = (AudioManager) ApplicationSingleton.instans.getSystemService(Context.AUDIO_SERVICE);
switch (focusChange) {
// Kommer ved f.eks. en SMS eller taleinstruktion i Google Maps
case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK):
Log.d("JPER duck");
if (afspillerstatus != Status.STOPPET) {
// Vi 'dukker' lyden mens den vigtigere lyd høres
// Sæt lydstyrken ned til en 1/3-del
//lydstyreFørDuck = am.getStreamVolume(AudioManager.STREAM_MUSIC);
//am.setStreamVolume(AudioManager.STREAM_MUSIC, (lydstyreFørDuck + 2) / 3, 0);
mediaPlayer.setVolume(0.1f, 0.1f); // logaritmisk skala - 0.1 svarer til 1/3-del
}
break;
// Dette sker ved f.eks. opkald
case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT):
Log.d("JPER pause");
if (afspillerstatus != Status.STOPPET) {
pauseAfspilning(); // sætter afspilningPåPause=false
if (afspillerlyde) afspillerlyd.stop.start();
afspilningPåPause = true;
}
break;
// Dette sker hvis en anden app med lyd startes, f.eks. et spil
case (AudioManager.AUDIOFOCUS_LOSS):
Log.d("JPER stop");
// stopAfspilning();
pauseAfspilning();
am.abandonAudioFocus(this);
break;
// Dette sker når opkaldet er slut og ved f.eks. opkald
case (AudioManager.AUDIOFOCUS_GAIN):
Log.d("JPER Gain");
if (afspillerstatus == Status.STOPPET) {
if (afspilningPåPause) startAfspilningIntern();
} else {
// Genskab lydstyrke før den blev dukket
mediaPlayer.setVolume(1f, 1f);
}
}
}
示例15: abandonFocus
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* Utility method to abandon audio focus given an AudioManager object
* @param am the AudioManager object
* @param afChangeListener the foucs listener associated to the AudioManager
*/
public static void abandonFocus(AudioManager am, Object afChangeListener) {
am.abandonAudioFocus((AudioManager.OnAudioFocusChangeListener) afChangeListener);
}