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


Java AudioManager.ACTION_AUDIO_BECOMING_NOISY属性代码示例

本文整理汇总了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;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:8,代码来源:EarphoneProtector.java

示例2: setListener

public void setListener(BecomingNoisyListener listener) {
    this.listener = listener;
    IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    context.registerReceiver(this, intentFilter);
}
 
开发者ID:12d,项目名称:react-native-videoplayer,代码行数:5,代码来源:AudioBecomingNoisyReceiver.java

示例3: registerBecomingNoisyReceiver

private void registerBecomingNoisyReceiver() {
    //register after getting audio focus
    IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    registerReceiver(becomingNoisyReceiver, intentFilter);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:5,代码来源:AudioService.java

示例4: onCreate

@Override
public void onCreate() {
    super.onCreate();
    IntentFilter filter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    registerReceiver(mAudioBecomingNoisyReceiver, filter);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:6,代码来源:MediaNotificationManager.java

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

示例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);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:55,代码来源:PlayerService.java

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

        }

    }
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:50,代码来源:PlayerService.java


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