本文整理匯總了Java中android.support.v4.media.session.PlaybackStateCompat.ACTION_PLAY_PAUSE屬性的典型用法代碼示例。如果您正苦於以下問題:Java PlaybackStateCompat.ACTION_PLAY_PAUSE屬性的具體用法?Java PlaybackStateCompat.ACTION_PLAY_PAUSE怎麽用?Java PlaybackStateCompat.ACTION_PLAY_PAUSE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v4.media.session.PlaybackStateCompat
的用法示例。
在下文中一共展示了PlaybackStateCompat.ACTION_PLAY_PAUSE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAvailableActions
private long getAvailableActions() {
long actions =
PlaybackStateCompat.ACTION_PLAY_PAUSE |
PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID |
PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH |
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
if (playback.isPlaying()) {
actions |= PlaybackStateCompat.ACTION_PAUSE;
} else {
actions |= PlaybackStateCompat.ACTION_PLAY;
}
//
if(isRepeat){
actions|=PlaybackStateCompat.ACTION_SET_REPEAT_MODE;
}
//
if(isShuffle){
actions|=PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE_ENABLED;
}
return actions;
}
示例2: getAvailableActions
@PlaybackStateCompat.Actions
private long getAvailableActions() {
long actions = PlaybackStateCompat.ACTION_PLAY_PAUSE
| PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID
| PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH;
if (mMediaPlayerGlue.isPlaying()) {
actions |= PlaybackStateCompat.ACTION_PAUSE;
} else {
actions |= PlaybackStateCompat.ACTION_PLAY;
}
return actions;
}
示例3: updatePlaybackState
/**
* Update the current media player state, optionally showing an error message.
*/
public void updatePlaybackState() {
long position = PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN;
if (mPlayback != null ) {
position = mPlayback.getCurrentPosition();
}
long actions =
PlaybackStateCompat.ACTION_PLAY_PAUSE |
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
if (mPlayback != null && mPlayback.isPlaying()) {
actions |= PlaybackStateCompat.ACTION_PAUSE;
} else {
actions |= PlaybackStateCompat.ACTION_PLAY;
}
int state = mPlayback.getState();
//noinspection ResourceType
PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder()
.setActions(actions)
.setState(state, position, 1.0f, SystemClock.elapsedRealtime());
mMediaSession.setPlaybackState(stateBuilder.build());
Intent intent = new Intent("change-playback-state-event");
intent.putExtra("state", state);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}
示例4: getAvailableActions
/**
* Set the current capabilities available on this session. Note: If a capability is not
* listed in the bitmask of capabilities then the MediaSession will not handle it. For
* example, if you don't want ACTION_STOP to be handled by the MediaSession, then don't
* included it in the bitmask that's returned.
*/
@PlaybackStateCompat.Actions
private long getAvailableActions() {
long actions = PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID
| PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH
| PlaybackStateCompat.ACTION_SKIP_TO_NEXT
| PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
switch (mState) {
case PlaybackStateCompat.STATE_STOPPED:
actions |= PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_PAUSE;
break;
case PlaybackStateCompat.STATE_PLAYING:
actions |= PlaybackStateCompat.ACTION_STOP
| PlaybackStateCompat.ACTION_PAUSE
| PlaybackStateCompat.ACTION_SEEK_TO;
break;
case PlaybackStateCompat.STATE_PAUSED:
actions |= PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_STOP;
break;
default:
actions |= PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_PLAY_PAUSE
| PlaybackStateCompat.ACTION_STOP
| PlaybackStateCompat.ACTION_PAUSE;
}
return actions;
}
示例5: getAvailableActions
/**
* Set the current capabilities available on this session. Note: If a capability is not
* listed in the bitmask of capabilities then the MediaSession will not handle it. For
* example, if you don't want ACTION_STOP to be handled by the MediaSession, then don't
* included it in the bitmask that's returned.
*/
@PlaybackStateCompat.Actions
private long getAvailableActions() {
long actions = PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID
| PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH
| PlaybackStateCompat.ACTION_SKIP_TO_NEXT
| PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
switch (mState) {
case PlaybackStateCompat.STATE_STOPPED:
actions |= PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_PAUSE;
break;
case PlaybackStateCompat.STATE_PLAYING:
actions |= PlaybackStateCompat.ACTION_STOP
| PlaybackStateCompat.ACTION_PAUSE
| PlaybackStateCompat.ACTION_SEEK_TO;
break;
case PlaybackStateCompat.STATE_PAUSED:
actions |= PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_STOP;
break;
default:
actions |= PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_PLAY_PAUSE
| PlaybackStateCompat.ACTION_STOP
| PlaybackStateCompat.ACTION_PAUSE;
}
return actions;
}