本文整理汇总了Java中android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY属性的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.ACTION_AUDIO_BECOMING_NOISY属性的具体用法?Java AudioManager.ACTION_AUDIO_BECOMING_NOISY怎么用?Java AudioManager.ACTION_AUDIO_BECOMING_NOISY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.ACTION_AUDIO_BECOMING_NOISY属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
@Override
public boolean start(Object obj) {
mReceiver = new EarphoneBroadcastReceiver();
IntentFilter filter = new IntentFilter(
AudioManager.ACTION_AUDIO_BECOMING_NOISY);
getmServiceContext().registerReceiver(mReceiver, filter);
return true;
}
示例2: setListener
public void setListener(BecomingNoisyListener listener) {
this.listener = listener;
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
context.registerReceiver(this, intentFilter);
}
示例3: registerBecomingNoisyReceiver
private void registerBecomingNoisyReceiver() {
//register after getting audio focus
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
registerReceiver(becomingNoisyReceiver, intentFilter);
}
示例4: onCreate
@Override
public void onCreate() {
super.onCreate();
IntentFilter filter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
registerReceiver(mAudioBecomingNoisyReceiver, filter);
}
示例5: registerHeadsetPlugReceiver
/**
* 参考: http://blog.csdn.net/mu399/article/details/38516039
* AudioManager.ACTION_AUDIO_BECOMING_NOISY: 只是针对有线耳机,或者无线耳机的手机断开连接的事件,无延迟.但监听不到有线耳机和蓝牙耳机的接入.
*/
private void registerHeadsetPlugReceiver() {
instance.becomingNoisyReceiver = new BecomingNoisyReceiver();
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
instance.context.registerReceiver(instance.becomingNoisyReceiver, intentFilter);
}
示例6: startPlayback
private void startPlayback() {
LogHelper.v(LOG_TAG, "Starting playback.");
// set and save state
mStationMetadata = mStation.getStationName();
mStationMetadataReceived = false;
mStation.setPlaybackState(true);
mPlayback = true;
mStationLoading = true;
mStationIDLast = mStationIDCurrent;
mStationIDCurrent = mStationID;
saveAppState();
// acquire Wifi and wake locks
if (!mWifiLock.isHeld()) {
mWifiLock.acquire();
}
if (!mWakeLock.isHeld()) {
mWakeLock.acquire(); // needs android.permission.WAKE_LOCK
}
// stop running mExoPlayer - request focus and initialize media mExoPlayer
if (mExoPlayer.getPlayWhenReady()) {
mExoPlayer.setPlayWhenReady(false);
mExoPlayer.stop();
NotificationHelper.stop();
}
if (mStreamUri != null && requestFocus()) {
// initialize player and start playback
initializeExoPlayer();
mExoPlayer.setPlayWhenReady(true);
// update MediaSession
mSession.setPlaybackState(getPlaybackState());
mSession.setMetadata(getMetadata(getApplicationContext(), mStation, mStationMetadata));
mSession.setActive(true);
// put up notification
NotificationHelper.show(this, mSession, mStation, mStationID, this.getString(R.string.descr_station_stream_loading));
}
// send local broadcast: buffering
Intent intent = new Intent();
intent.setAction(ACTION_PLAYBACK_STATE_CHANGED);
intent.putExtra(EXTRA_PLAYBACK_STATE_CHANGE, PLAYBACK_LOADING_STATION);
intent.putExtra(EXTRA_STATION, mStation);
intent.putExtra(EXTRA_STATION_ID, mStationID);
LocalBroadcastManager.getInstance(this.getApplication()).sendBroadcast(intent);
// register headphone listener
IntentFilter headphoneUnplugIntentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
mHeadphoneUnplugReceiver = new HeadphoneUnplugReceiver();
registerReceiver(mHeadphoneUnplugReceiver, headphoneUnplugIntentFilter);
}
示例7: startPlayback
private void startPlayback() {
// set and save state
mStationMetadata = mStation.TITLE;
mStationMetadataReceived = false;
mStation.setPlaybackState(true);
mPlayback = true;
mStationLoading = true;
saveAppState();
// acquire Wifi lock
if (!mWifiLock.isHeld()) {
mWifiLock.acquire();
}
// register headphone unplug receiver
IntentFilter headphoneUnplugIntentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
mHeadphoneUnplugReceiver = new HeadphoneUnplugReceiver();
registerReceiver(mHeadphoneUnplugReceiver, headphoneUnplugIntentFilter);
// send local broadcast
Intent i = new Intent();
i.setAction(TransistorKeys.ACTION_PLAYBACK_STATE_CHANGED);
i.putExtra(TransistorKeys.EXTRA_PLAYBACK_STATE_CHANGE, TransistorKeys.PLAYBACK_LOADING_STATION);
i.putExtra(TransistorKeys.EXTRA_STATION, mStation);
i.putExtra(TransistorKeys.EXTRA_STATION_Position_ID, mStationID_Position);
LocalBroadcastManager.getInstance(this.getApplication()).sendBroadcast(i);
// increase counter
mPlayerInstanceCounter++;
// stop running player - request focus and initialize media player
if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
releaseMediaPlayer();
NotificationHelper.stop();
}
if (mStreamUri != null && requestFocus()) {
initializeMediaPlayer();
// update MediaSession
mSession.setPlaybackState(getPlaybackState());
mSession.setMetadata(getMetadata(getApplicationContext(), mStation, mStationMetadata));
mSession.setActive(true);
// put up notification
NotificationHelper.show(this, mSession, mStation, mStationID_Position, this.getString(R.string.descr_station_stream_loading));
}
}