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


Java RemoteControlClient.FLAG_KEY_MEDIA_PLAY属性代码示例

本文整理汇总了Java中android.media.RemoteControlClient.FLAG_KEY_MEDIA_PLAY属性的典型用法代码示例。如果您正苦于以下问题:Java RemoteControlClient.FLAG_KEY_MEDIA_PLAY属性的具体用法?Java RemoteControlClient.FLAG_KEY_MEDIA_PLAY怎么用?Java RemoteControlClient.FLAG_KEY_MEDIA_PLAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.RemoteControlClient的用法示例。


在下文中一共展示了RemoteControlClient.FLAG_KEY_MEDIA_PLAY属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerRemote

/**
 * Perform initialization required for RemoteControlClient.
 *
 * @param context A context to use.
 * @param am The AudioManager service.
 */
public static void registerRemote(Context context, AudioManager am)
{
	if (!MediaButtonReceiver.useHeadsetControls(context)) {
		// RemoteControlClient requires MEDIA_BUTTON intent
		return;
	}

	MediaButtonReceiver.registerMediaButton(context);

	Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
	mediaButtonIntent.setComponent(new ComponentName(context.getPackageName(), MediaButtonReceiver.class.getName()));
	PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0, mediaButtonIntent, 0);
	RemoteControlClient remote = new RemoteControlClient(mediaPendingIntent);
	int flags = RemoteControlClient.FLAG_KEY_MEDIA_NEXT
		| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
		| RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
		| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
		| RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
	remote.setTransportControlFlags(flags);
	am.registerRemoteControlClient(remote);
	sRemote = remote;
}
 
开发者ID:owoc,项目名称:teardrop,代码行数:28,代码来源:CompatIcs.java

示例2: setUpRemoteControlClient

/**
 * Initializes the remote control client
 */
private void setUpRemoteControlClient() {
    if (mEnableLockscreenControls) {
        if (mRemoteControlClientCompat == null) {
            final Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
            mediaButtonIntent.setComponent(mMediaButtonReceiverComponent);
            mRemoteControlClientCompat = new RemoteControlClientCompat(
                    PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent,
                            PendingIntent.FLAG_UPDATE_CURRENT));
            RemoteControlHelper.registerRemoteControlClient(mAudioManager,
                    mRemoteControlClientCompat);
        }
        // Flags for the media transport control that this client supports.
        final int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
                | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
                | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
                | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
                | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
                | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
        mRemoteControlClientCompat.setTransportControlFlags(flags);
    }
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:24,代码来源:MusicPlaybackService.java

示例3: registerRemote

public static void registerRemote(Context context, AudioManager am) {
    MediaButtonReceiver.registerMediaButton(context);

    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setComponent(new ComponentName(context.getPackageName(),
            MediaButtonReceiver.class.getName()));
    PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0,
            mediaButtonIntent, 0);
    RemoteControlClient remote = new RemoteControlClient(mediaPendingIntent);
    int flags = RemoteControlClient.FLAG_KEY_MEDIA_NEXT
            | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
            | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
    remote.setTransportControlFlags(flags);
    am.registerRemoteControlClient(remote);
    sRemote = remote;
}
 
开发者ID:PavelKorolev,项目名称:liquid-bear-android,代码行数:18,代码来源:CompatIcs.java

示例4: getTransportFlags

protected int getTransportFlags() {
	return RemoteControlClient.FLAG_KEY_MEDIA_PLAY | 
		RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | 
		RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
		RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
		RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
		RemoteControlClient.FLAG_KEY_MEDIA_STOP;
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:8,代码来源:RemoteControlClientICS.java

示例5: getFlags

int getFlags() {
    return RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
            | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
            | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:8,代码来源:MediaSessionHelper.java

示例6: onCreate

@SuppressLint({ "WorldWriteableFiles", "WorldReadableFiles" })
@Override
   public void onCreate() {
       super.onCreate();

       mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
       ComponentName rec = new ComponentName(getPackageName(),
               MediaButtonIntentReceiver.class.getName());
       mAudioManager.registerMediaButtonEventReceiver(rec);

       Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
       mediaButtonIntent.setComponent(rec);
       PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,
               mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT);

       mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
       mAudioManager.registerRemoteControlClient(mRemoteControlClient);

       int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
               | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
               | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
               | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
               | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
       mRemoteControlClient.setTransportControlFlags(flags);

       mPreferences = getSharedPreferences(APOLLO_PREFERENCES, MODE_WORLD_READABLE
               | MODE_WORLD_WRITEABLE);
       mCardId = MusicUtils.getCardId(this);

       registerExternalStorageListener();

       // Needs to be done in this thread, since otherwise
       // ApplicationContext.getPowerManager() crashes.
       mPlayer = new MultiPlayer();
       mPlayer.setHandler(mMediaplayerHandler);

       reloadQueue();
       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);
       commandFilter.addAction(CYCLEREPEAT_ACTION);
       commandFilter.addAction(TOGGLESHUFFLE_ACTION);
       registerReceiver(mIntentReceiver, commandFilter);

       PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);

       mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());

       mWakeLock.setReferenceCounted(false);

       // 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:hubcarl,项目名称:mobile-manager-tool,代码行数:62,代码来源:ApolloService.java

示例7: ensureTransportControls

private static void ensureTransportControls(MediaSessionCompat session, PlaybackStateCompat playbackState) {
    long actions = playbackState.getActions();
    Object remoteObj = session.getRemoteControlClient();
    if(actions != 0 && remoteObj != null) {

        int transportControls = 0;

        if((actions & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS;
        }

        if((actions & PlaybackStateCompat.ACTION_REWIND) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_REWIND;
        }

        if((actions & PlaybackStateCompat.ACTION_PLAY) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PLAY;
        }

        if((actions & PlaybackStateCompat.ACTION_PLAY_PAUSE) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE;
        }

        if((actions & PlaybackStateCompat.ACTION_PAUSE) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
        }

        if((actions & PlaybackStateCompat.ACTION_STOP) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_STOP;
        }

        if((actions & PlaybackStateCompat.ACTION_FAST_FORWARD) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD;
        }

        if((actions & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_NEXT;
        }

        if((actions & PlaybackStateCompat.ACTION_SEEK_TO) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE;
        }

        if((actions & PlaybackStateCompat.ACTION_SET_RATING) != 0){
            transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_RATING;
        }

        ((RemoteControlClient)remoteObj).setTransportControlFlags(transportControls);
    }
}
 
开发者ID:Wojtechnology,项目名称:Sunami,代码行数:50,代码来源:MediaSessionCompatHelper.java

示例8: handleKeyEvent

public void handleKeyEvent(KeyEvent event) {
	if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() > 0) {
		switch (event.getKeyCode()) {
			case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
			case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
				downloadService.fastForward();
				break;
			case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
			case KeyEvent.KEYCODE_MEDIA_NEXT:
				downloadService.rewind();
				break;
		}
	} else if(event.getAction() == KeyEvent.ACTION_UP) {
		switch (event.getKeyCode()) {
			case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
				downloadService.togglePlayPause();
				break;
			case KeyEvent.KEYCODE_HEADSETHOOK:
			case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
				if(lastPressTime < (System.currentTimeMillis() - 500)) {
					lastPressTime = System.currentTimeMillis();
					downloadService.togglePlayPause();
				} else {
					downloadService.next(false, true);
				}
				break;
			case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
			case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
				if(lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) {
					lastPressTime = System.currentTimeMillis();
					downloadService.previous();
				}
				break;
			case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
			case KeyEvent.KEYCODE_MEDIA_NEXT:
				if(lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) {
					lastPressTime = System.currentTimeMillis();
					downloadService.next();
				}
				break;
			case KeyEvent.KEYCODE_MEDIA_REWIND:
				downloadService.rewind();
				break;
			case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
				downloadService.fastForward();
				break;
			case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
			case KeyEvent.KEYCODE_MEDIA_STOP:
				downloadService.stop();
				break;
			case RemoteControlClient.FLAG_KEY_MEDIA_PLAY:
			case KeyEvent.KEYCODE_MEDIA_PLAY:
				if(downloadService.getPlayerState() != PlayerState.STARTED) {
					downloadService.start();
				}
				break;
			case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE:
			case KeyEvent.KEYCODE_MEDIA_PAUSE:
				downloadService.pause();
			default:
				break;
		}
	}
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:64,代码来源:DownloadServiceLifecycleSupport.java

示例9: handleKeyEvent

private void handleKeyEvent(KeyEvent event) {
    if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0) {
        return;
    }

    switch (event.getKeyCode()) {
    case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
    case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
    case KeyEvent.KEYCODE_HEADSETHOOK:
    	downloadService.togglePlayPause();
    	break;
    	
    case KeyEvent.KEYCODE_STAR:
    	downloadService.toggleStarred();
    	break;
    	
    case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
    	downloadService.previous();
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
    case KeyEvent.KEYCODE_MEDIA_NEXT:
    	if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
    		downloadService.next();
    	}
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
    case KeyEvent.KEYCODE_MEDIA_STOP:
    	downloadService.stop();
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_PLAY:
    case KeyEvent.KEYCODE_MEDIA_PLAY:
    	if(downloadService.getPlayerState() != PlayerState.STARTED) {
    		downloadService.start();
    	}
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE:
    case KeyEvent.KEYCODE_MEDIA_PAUSE:
    	downloadService.pause();
    default:
    	break;
    }
}
 
开发者ID:MadMarty,项目名称:madsonic-5.5,代码行数:43,代码来源:DownloadServiceLifecycleSupport.java

示例10: onCreate

@SuppressLint({ "WorldWriteableFiles", "WorldReadableFiles" })
@Override
   public void onCreate() {
       super.onCreate();

       mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
       ComponentName rec = new ComponentName(getPackageName(),
               MediaButtonIntentReceiver.class.getName());
       mAudioManager.registerMediaButtonEventReceiver(rec);
       Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
       mediaButtonIntent.setComponent(rec);
       PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,
               mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT);
       mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
       mAudioManager.registerRemoteControlClient(mRemoteControlClient);

       int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
               | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
               | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
               | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
               | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
       mRemoteControlClient.setTransportControlFlags(flags);

       mPreferences = getSharedPreferences(APOLLO_PREFERENCES, MODE_WORLD_READABLE
               | MODE_WORLD_WRITEABLE);
       mCardId = MusicUtils.getCardId(this);

       registerExternalStorageListener();

       // Needs to be done in this thread, since otherwise
       // ApplicationContext.getPowerManager() crashes.
       mPlayer = new MultiPlayer();
       mPlayer.setHandler(mMediaplayerHandler);

       reloadQueue();
       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);
       commandFilter.addAction(CYCLEREPEAT_ACTION);
       commandFilter.addAction(TOGGLESHUFFLE_ACTION);
       registerReceiver(mIntentReceiver, commandFilter);

       PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
       mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
       mWakeLock.setReferenceCounted(false);

       // 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:cpoopc,项目名称:com.cp.monsterMod,代码行数:58,代码来源:ApolloService.java

示例11: onCreate

@SuppressLint({ "WorldWriteableFiles", "WorldReadableFiles" })
@Override
   public void onCreate() {
       super.onCreate();

       mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
       ComponentName rec = new ComponentName(getPackageName(),
               MediaButtonIntentReceiver.class.getName());
       mAudioManager.registerMediaButtonEventReceiver(rec);
       Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
       mediaButtonIntent.setComponent(rec);
       PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,
               mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT);
       mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
       mAudioManager.registerRemoteControlClient(mRemoteControlClient);

       int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
               | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
               | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
               | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
               | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
       mRemoteControlClient.setTransportControlFlags(flags);

       mPreferences = getSharedPreferences(APOLLO_PREFERENCES, MODE_WORLD_READABLE
               | MODE_WORLD_WRITEABLE);
       mCardId = MusicUtils.getCardId(this);

       registerExternalStorageListener();

       // Needs to be done in this thread, since otherwise
       // ApplicationContext.getPowerManager() crashes.
       mPlayer = new MultiPlayer();
       mPlayer.setHandler(mMediaplayerHandler);

       reloadQueue();
       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);
       commandFilter.addAction(CYCLEREPEAT_ACTION);
       commandFilter.addAction(TOGGLESHUFFLE_ACTION);
       registerReceiver(mIntentReceiver, commandFilter);

       PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
       mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
       mWakeLock.setReferenceCounted(false);

       // 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:liufeiit,项目名称:itmarry,代码行数:58,代码来源:ApolloService.java

示例12: handleKeyEvent

private void handleKeyEvent(KeyEvent event) {
    if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0) {
        return;
    }

    switch (event.getKeyCode()) {
    case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
    case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
    case KeyEvent.KEYCODE_HEADSETHOOK:
    	downloadService.togglePlayPause();
    	break;
    	
    case KeyEvent.KEYCODE_STAR:
    	downloadService.toggleStarred();
    	break;
    	
    case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
    	downloadService.previous();
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
    case KeyEvent.KEYCODE_MEDIA_NEXT:
    	if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
    		downloadService.next();
    	}
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
    case KeyEvent.KEYCODE_MEDIA_STOP:
    	downloadService.reset();
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_PLAY:
    case KeyEvent.KEYCODE_MEDIA_PLAY:
    	if(downloadService.getPlayerState() != PlayerState.STARTED) {
    		downloadService.start();
    	}
    	break;
    case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE:
    case KeyEvent.KEYCODE_MEDIA_PAUSE:
    	downloadService.pause();
    default:
    	break;
    }
}
 
开发者ID:MadMarty,项目名称:madsonic-5.6,代码行数:43,代码来源:DownloadServiceLifecycleSupport.java

示例13: onCreate

@Override
public void onCreate() {
    super.onCreate();

    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    ComponentName rec = new ComponentName(getPackageName(),
            MediaButtonIntentReceiver.class.getName());
    mAudioManager.registerMediaButtonEventReceiver(rec);

    Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
    i.setComponent(rec);
    PendingIntent pi = PendingIntent.getBroadcast(this /*context*/,
            0 /*requestCode, ignored*/, i /*intent*/, 0 /*flags*/);
    mRemoteControlClient = new RemoteControlClient(pi);
    mAudioManager.registerRemoteControlClient(mRemoteControlClient);

    int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
            | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
            | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
    mRemoteControlClient.setTransportControlFlags(flags);
    
    mPreferences = getSharedPreferences("Music", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);
    mCardId = MusicUtils.getCardId(this);
    
    registerExternalStorageListener();

    // Needs to be done in this thread, since otherwise ApplicationContext.getPowerManager() crashes.
    mPlayer = new MultiPlayer();
    mPlayer.setHandler(mMediaplayerHandler);

    reloadQueue();
    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);
    
    PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
    mWakeLock.setReferenceCounted(false);

    // 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:AndroidLearnerchn,项目名称:Android-Application-Using-CAF-Library,代码行数:54,代码来源:MediaPlaybackService.java


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