当前位置: 首页>>代码示例>>Java>>正文


Java AudioManager.abandonAudioFocus方法代码示例

本文整理汇总了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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:21,代码来源:SignalAudioManager.java

示例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);
        }
    }
}
 
开发者ID:TongmingWu,项目名称:BLPlayer,代码行数:17,代码来源:IjkVideoView.java

示例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;

    }
 
开发者ID:qq1210514049,项目名称:ListVideoPlayer,代码行数:26,代码来源:ListVideoPlayer.java

示例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;
    }
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:25,代码来源:JCVideoPlayer.java

示例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;
    }
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:25,代码来源:JCVideoPlayer.java

示例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);
    }
}
 
开发者ID:jiajunhui,项目名称:PlayerBase,代码行数:15,代码来源:IjkVideoView.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:IjkVideoView.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:IjkVideoView.java

示例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);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:LivePlayerHolder.java

示例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);
    }
}
 
开发者ID:khizar1556,项目名称:MKVideoPlayer,代码行数:12,代码来源:IjkVideoView.java

示例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);
    }
}
 
开发者ID:jiajunhui,项目名称:PlayerBase,代码行数:14,代码来源:IjkVideoView.java

示例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);
    }
}
 
开发者ID:lanyan520,项目名称:Idea-ijkplayer,代码行数:15,代码来源:IjkVideoView.java

示例13: abandonAudioFocus

import android.media.AudioManager; //导入方法依赖的package包/类
/**
 * 释放音频焦点
 */
public static void abandonAudioFocus(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.abandonAudioFocus(null);//放弃焦点
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:8,代码来源:RUtils.java

示例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);
      }
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:47,代码来源:Afspiller.java

示例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);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:9,代码来源:FroyoUtil.java


注:本文中的android.media.AudioManager.abandonAudioFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。