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


Java MediaButtonIntentReceiver类代码示例

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

示例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);
  }
 
开发者ID:minstrelsy,项目名称:servestream,代码行数:57,代码来源:MediaPlaybackService.java


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