Android歌词秀设计思路(4)通用的音乐播放服务(下)(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-10 12:24 点击:次
break;
default:
}
}
};
mFocusable = focusable;
}else{
mAudioFocus = Focused; // no focus feature, so we always "have" audio focus
}
}
/** Requests audio focus. Returns whether request was successful or not. */
public boolean requestFocus() {
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED ==
mAM.requestAudioFocus(mListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
}
/** Abandons audio focus. Returns whether request was successful or not. */
public boolean abandonFocus() {
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAM.abandonAudioFocus(mListener);
}
public void giveUpAudioFocus() {
if (mAudioFocus == Focused
&& android.os.Build.VERSION.SDK_INT >= 8
&& abandonFocus())
mAudioFocus = NoFocusNoDuck;
}
public void tryToGetAudioFocus() {
if (mAudioFocus != Focused
&& android.os.Build.VERSION.SDK_INT >= 8
&& requestFocus())
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>