本文整理汇总了Java中android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction类的典型用法代码示例。如果您正苦于以下问题:Java PlayPauseAction类的具体用法?Java PlayPauseAction怎么用?Java PlayPauseAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayPauseAction类属于android.support.v17.leanback.widget.PlaybackControlsRow包,在下文中一共展示了PlayPauseAction类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: togglePlayback
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
public void togglePlayback(boolean playPause) {
if (playPause) {
startProgressAutomation();
setFadingEnabled(true);
mCallback.onFragmentPlayPause(mItems.get(mCurrentItem),
mPlaybackControlsRow.getCurrentTime(), true);
mPlayPauseAction.setIcon(mPlayPauseAction.getDrawable(PlayPauseAction.PAUSE));
} else {
stopProgressAutomation();
setFadingEnabled(false);
mCallback.onFragmentPlayPause(mItems.get(mCurrentItem),
mPlaybackControlsRow.getCurrentTime(), false);
mPlayPauseAction.setIcon(mPlayPauseAction.getDrawable(PlayPauseAction.PLAY));
}
notifyChanged(mPlayPauseAction);
}
示例2: onActionClicked
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
@Override
public void onActionClicked(@NonNull Action action) {
if (action.getId() == mPlayPauseAction.getId()) {
invokeTogglePlaybackAction(mPlayPauseAction.getIndex() == PlayPauseAction.PLAY);
}
else if (action.getId() == mScaleVideoAction.getId()) {
invokeScaleVideoAction();
}
else if (action.getId() == mClosedCaptioningAction.getId()) {
invokeOpenSubtitleSettingsAction();
}
if (mSkipPreviousAction != null && action.getId() == mSkipPreviousAction.getId()) {
playSelectedEpisode(mPreviousEpisode);
}
if (mSkipNextAction != null && action.getId() == mSkipNextAction.getId()) {
playSelectedEpisode(mNextEpisode);
}
if (action instanceof PlaybackControlsRow.MultiAction) {
notifyPlaybackControlActionChanged(action);
}
}
示例3: setupPlaybackControlItemsToInitialisingState
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
private void setupPlaybackControlItemsToInitialisingState() {
mRowsAdapter.clear();
mPlaybackControlsRow = new PlaybackControlsRow(mStreamInfo);
mPlaybackControlsRow.setCurrentTime(0);
mPlaybackControlsRow.setBufferedProgress(0);
ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector();
mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter);
Activity activity = getActivity();
mPlayPauseAction = new PlayPauseAction(activity);
mPrimaryActionsAdapter.add(mPlayPauseAction);
setupSecondaryRowPlaybackControl(presenterSelector);
mRowsAdapter.add(mPlaybackControlsRow);
mRowsAdapter.notifyArrayItemRangeChanged(0, mRowsAdapter.size());
}
示例4: setupPrimaryRowPlaybackControl
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
private void setupPrimaryRowPlaybackControl(@NonNull ControlButtonPresenterSelector presenterSelector) {
mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter);
Activity activity = getActivity();
mPlayPauseAction = new PlayPauseAction(activity);
mFastForwardAction = new FastForwardAction(activity);
mRewindAction = new RewindAction(activity);
if (mPreviousEpisode != null) {
mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(activity);
mPrimaryActionsAdapter.add(mSkipPreviousAction);
}
// Add main controls to primary adapter.
mPrimaryActionsAdapter.add(mRewindAction);
mPrimaryActionsAdapter.add(mPlayPauseAction);
mPrimaryActionsAdapter.add(mFastForwardAction);
if (mNextEpisode != null) {
mSkipNextAction = new PlaybackControlsRow.SkipNextAction(activity);
mPrimaryActionsAdapter.add(mSkipNextAction);
}
}
示例5: addPlaybackControlsRow
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
private void addPlaybackControlsRow(MediaMetadata metadata) {
mPlaybackControlsRow = new PlaybackControlsRow(new MutableMediaMetadataHolder(metadata));
mRowsAdapter.add(mPlaybackControlsRow);
resetPlaybackRow();
ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector();
mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter);
mPlayPauseAction = new PlayPauseAction(getActivity());
mSkipNextAction = new PlaybackControlsRow.SkipNextAction(getActivity());
mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(getActivity());
mPrimaryActionsAdapter.add(mSkipPreviousAction);
mPrimaryActionsAdapter.add(mPlayPauseAction);
mPrimaryActionsAdapter.add(mSkipNextAction);
}
示例6: updatePlaybackState
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
protected void updatePlaybackState(PlaybackState state) {
if (mPlaybackControlsRow == null) {
// We only update playback state after we get a valid metadata.
return;
}
mLastPosition = state.getPosition();
mLastPositionUpdateTime = state.getLastPositionUpdateTime();
switch (state.getState()) {
case PlaybackState.STATE_PLAYING:
startProgressAutomation();
mPlayPauseAction.setIndex(PlayPauseAction.PAUSE);
break;
case PlaybackState.STATE_PAUSED:
stopProgressAutomation();
mPlayPauseAction.setIndex(PlayPauseAction.PLAY);
break;
}
updatePlayListRow(getActivity().getMediaController().getQueue());
mRowsAdapter.notifyArrayItemRangeChanged(
mRowsAdapter.indexOf(mPlaybackControlsRow), 1);
}
示例7: addPlaybackControlsRow
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
private void addPlaybackControlsRow(MediaMetadataCompat metadata) {
mPlaybackControlsRow = new PlaybackControlsRow(new MutableMediaMetadataHolder(metadata));
mRowsAdapter.add(mPlaybackControlsRow);
resetPlaybackRow();
ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector();
mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter);
mPlayPauseAction = new PlayPauseAction(getActivity());
mSkipNextAction = new PlaybackControlsRow.SkipNextAction(getActivity());
mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(getActivity());
mPrimaryActionsAdapter.add(mSkipPreviousAction);
mPrimaryActionsAdapter.add(mPlayPauseAction);
mPrimaryActionsAdapter.add(mSkipNextAction);
}
示例8: updatePlaybackState
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
protected void updatePlaybackState(PlaybackStateCompat state) {
if (mPlaybackControlsRow == null) {
// We only update playback state after we get a valid metadata.
return;
}
mLastPosition = state.getPosition();
mLastPositionUpdateTime = state.getLastPositionUpdateTime();
switch (state.getState()) {
case PlaybackStateCompat.STATE_PLAYING:
startProgressAutomation();
mPlayPauseAction.setIndex(PlayPauseAction.PAUSE);
break;
case PlaybackStateCompat.STATE_PAUSED:
stopProgressAutomation();
mPlayPauseAction.setIndex(PlayPauseAction.PLAY);
break;
}
MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity());
updatePlayListRow(controller.getQueue());
mRowsAdapter.notifyArrayItemRangeChanged(
mRowsAdapter.indexOf(mPlaybackControlsRow), 1);
}
示例9: onPlaybackStateChanged
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
@Override
public void onPlaybackStateChanged(PlaybackState state) {
Log.d(TAG, "playback state changed: " + state.getState());
if (state.getState() == PlaybackState.STATE_PLAYING && mCurrentPlaybackState != PlaybackState.STATE_PLAYING) {
mCurrentPlaybackState = PlaybackState.STATE_PLAYING;
startProgressAutomation();
setFadingEnabled(true);
mPlayPauseAction.setIndex(PlayPauseAction.PAUSE);
mPlayPauseAction.setIcon(mPlayPauseAction.getDrawable(PlayPauseAction.PAUSE));
notifyChanged(mPlayPauseAction);
} else if (state.getState() == PlaybackState.STATE_PAUSED && mCurrentPlaybackState != PlaybackState.STATE_PAUSED) {
mCurrentPlaybackState = PlaybackState.STATE_PAUSED;
stopProgressAutomation();
setFadingEnabled(false);
mPlayPauseAction.setIndex(PlayPauseAction.PLAY);
mPlayPauseAction.setIcon(mPlayPauseAction.getDrawable(PlayPauseAction.PLAY));
notifyChanged(mPlayPauseAction);
}
int currentTime = (int)state.getPosition();
mPlaybackControlsRow.setCurrentTime(currentTime);
mPlaybackControlsRow.setBufferedProgress(currentTime + SIMULATED_BUFFERED_TIME);
}
示例10: next
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
private void next() {
if (++mCurrentItem >= mItems.size()) {
mCurrentItem = 0;
}
if (mPlayPauseAction.getIndex() == PlayPauseAction.PLAY) {
mCallback.onFragmentPlayPause(mItems.get(mCurrentItem), 0, false);
} else {
mCallback.onFragmentPlayPause(mItems.get(mCurrentItem), 0, true);
}
updatePlaybackRow(mCurrentItem);
}
示例11: prev
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
private void prev() {
if (--mCurrentItem < 0) {
mCurrentItem = mItems.size() - 1;
}
if (mPlayPauseAction.getIndex() == PlayPauseAction.PLAY) {
mCallback.onFragmentPlayPause(mItems.get(mCurrentItem), 0, false);
} else {
mCallback.onFragmentPlayPause(mItems.get(mCurrentItem), 0, true);
}
updatePlaybackRow(mCurrentItem);
}
示例12: onPause
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
@Override
public void onPause() {
super.onPause();
if (!mKeepEventBusRegistration) {
// Event is unregistered before playback paused event is sent
mPlayPauseAction.setIndex(PlayPauseAction.PLAY);
setFadingEnabled(false);
notifyPlaybackControlActionChanged(mPlayPauseAction);
EventBus.getDefault().unregister(this);
}
}
示例13: onPlaybackStateChanged
import android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction; //导入依赖的package包/类
@Override
public void onPlaybackStateChanged(@NonNull PlaybackState state) {
if (state.getState() == PlaybackState.STATE_PLAYING
&& mCurrentPlaybackState == PlaybackState.STATE_PLAYING) {
startProgressAutomation();
setFadingEnabled(true);
} else if (state.getState() == PlaybackState.STATE_PLAYING) {
mCurrentPlaybackState = PlaybackState.STATE_PLAYING;
startProgressAutomation();
setFadingEnabled(true);
mPlayPauseAction.setIndex(PlayPauseAction.PAUSE);
mPlayPauseAction.setIcon(mPlayPauseAction.getDrawable(PlayPauseAction.PAUSE));
notifyChanged(mPlayPauseAction);
} else if (state.getState() == PlaybackState.STATE_PAUSED
&& mCurrentPlaybackState != PlaybackState.STATE_PAUSED) {
mCurrentPlaybackState = PlaybackState.STATE_PAUSED;
stopProgressAutomation();
setFadingEnabled(false);
mPlayPauseAction.setIndex(PlayPauseAction.PLAY);
mPlayPauseAction.setIcon(mPlayPauseAction.getDrawable(PlayPauseAction.PLAY));
notifyChanged(mPlayPauseAction);
}
int currentTime;
if (state.getState() == PlaybackState.STATE_PAUSED
|| state.getState() == PlaybackState.STATE_PLAYING) {
currentTime = mPlaybackControlsRow.getCurrentTime();
} else {
currentTime = (int) state.getPosition();
}
mPlaybackControlsRow.setCurrentTime(currentTime);
mPlaybackControlsRow.setBufferedProgress(currentTime + SIMULATED_BUFFERED_TIME);
}