本文整理匯總了Java中net.sourceforge.servestream.receiver.MediaButtonIntentReceiver類的典型用法代碼示例。如果您正苦於以下問題:Java MediaButtonIntentReceiver類的具體用法?Java MediaButtonIntentReceiver怎麽用?Java MediaButtonIntentReceiver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MediaButtonIntentReceiver類屬於net.sourceforge.servestream.receiver包,在下文中一共展示了MediaButtonIntentReceiver類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import net.sourceforge.servestream.receiver.MediaButtonIntentReceiver; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
Log.v(TAG, "onCreate called");
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mPreferences.registerOnSharedPreferenceChangeListener(this);
final boolean lockingWifi = mPreferences.getBoolean(PreferenceConstants.WIFI_LOCK, true);
mConnectivityManager = new ConnectivityReceiver(this, lockingWifi);
final boolean retrieveSHOUTcastMetadata = mPreferences.getBoolean(PreferenceConstants.RETRIEVE_SHOUTCAST_METADATA, false);
mSHOUTcastMetadata = new SHOUTcastMetadata(this, retrieveSHOUTcastMetadata);
mDownloadManager = new DownloadManager(this);
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mMediaButtonReceiverComponent = new ComponentName(this, MediaButtonIntentReceiver.class);
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
// Needs to be done in this thread, since otherwise ApplicationContext.getPowerManager() crashes.
mPlayer = new MultiPlayer();
mPlayer.setHandler(mMediaplayerHandler);
reloadSettings();
IntentFilter commandFilter = new IntentFilter();
commandFilter.addAction(SERVICECMD);
commandFilter.addAction(TOGGLEPAUSE_ACTION);
commandFilter.addAction(PAUSE_ACTION);
commandFilter.addAction(NEXT_ACTION);
registerReceiver(mIntentReceiver, commandFilter);
commandFilter = new IntentFilter();
commandFilter.addAction(Intent.ACTION_DOCK_EVENT);
registerReceiver(mDockReceiver,commandFilter);
// If the service was idle, but got killed before it stopped itself, the
// system will relaunch it. Make sure it gets stopped again in that case.
Message msg = mDelayedStopHandler.obtainMessage();
mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY);
}
示例2: onCreate
import net.sourceforge.servestream.receiver.MediaButtonIntentReceiver; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mMediaButtonReceiverComponent = new ComponentName(this, MediaButtonIntentReceiver.class);
mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent);
// Use the remote control APIs (if available) to set the playback state
if (mRemoteControlClientCompat == null) {
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.setComponent(mMediaButtonReceiverComponent);
mRemoteControlClientCompat = new RemoteControlClientCompat(
PendingIntent.getBroadcast(this /*context*/,
0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/));
RemoteControlHelper.registerRemoteControlClient(mAudioManager,
mRemoteControlClientCompat);
}
mRemoteControlClientCompat.setTransportControlFlags(
RemoteControlClientCompat.FLAG_KEY_MEDIA_PREVIOUS |
RemoteControlClientCompat.FLAG_KEY_MEDIA_PLAY |
RemoteControlClientCompat.FLAG_KEY_MEDIA_PAUSE |
RemoteControlClientCompat.FLAG_KEY_MEDIA_NEXT |
RemoteControlClientCompat.FLAG_KEY_MEDIA_STOP);
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mPreferences.registerOnSharedPreferenceChangeListener(this);
final boolean lockingWifi = mPreferences.getBoolean(PreferenceConstants.WIFI_LOCK, true);
mConnectivityManager = new ConnectivityReceiver(this, lockingWifi);
mRetrieveShoutCastMetadata = mPreferences.getBoolean(PreferenceConstants.RETRIEVE_SHOUTCAST_METADATA, false);
mMediaButtonReceiverComponent = new ComponentName(this, MediaButtonIntentReceiver.class);
// Needs to be done in this thread, since otherwise ApplicationContext.getPowerManager() crashes.
mPlayer = new MultiPlayer(this);
reloadSettings();
notifyChange(QUEUE_CHANGED);
//notifyChange(META_CHANGED);
IntentFilter commandFilter = new IntentFilter();
commandFilter.addAction(SERVICECMD);
commandFilter.addAction(TOGGLEPAUSE_ACTION);
commandFilter.addAction(PAUSE_ACTION);
commandFilter.addAction(NEXT_ACTION);
commandFilter.addAction(PREVIOUS_ACTION);
registerReceiver(mIntentReceiver, commandFilter);
// If the service was idle, but got killed before it stopped itself, the
// system will relaunch it. Make sure it gets stopped again in that case.
Message msg = mDelayedStopHandler.obtainMessage();
mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY);
}