android.support.v17.leanback.widget.PlaybackControlsRow Java Examples
The following examples show how to use
android.support.v17.leanback.widget.PlaybackControlsRow.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 6 votes |
private void notifyActionChanged(PlaybackControlsRow.MultiAction action) { int index = -1; if (getPrimaryActionsAdapter() != null) { index = getPrimaryActionsAdapter().indexOf(action); } if (index >= 0) { getPrimaryActionsAdapter().notifyArrayItemRangeChanged(index, 1); } else { if (getSecondaryActionsAdapter() != null) { index = getSecondaryActionsAdapter().indexOf(action); if (index >= 0) { getSecondaryActionsAdapter().notifyArrayItemRangeChanged(index, 1); } } } }
Example #2
Source File: PrimaryPlaybackControlsGlue.java From leanback-assistant with Apache License 2.0 | 5 votes |
public PrimaryPlaybackControlsGlue( Context context, T adapter, MediaControllerCompat mediaController) { super(context, adapter); mMediaSessionTransportControls = mediaController.getTransportControls(); mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(context); mSkipNextAction = new PlaybackControlsRow.SkipNextAction(context); mFastForwardAction = new PlaybackControlsRow.FastForwardAction(context); mRewindAction = new PlaybackControlsRow.RewindAction(context); }
Example #3
Source File: VideoMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
public VideoMediaPlayerGlue(Activity context, T impl) { super(context, impl); mClosedCaptioningAction = new PlaybackControlsRow.ClosedCaptioningAction(context); mThumbsUpAction = new PlaybackControlsRow.ThumbsUpAction(context); mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsUpAction.OUTLINE); mThumbsDownAction = new PlaybackControlsRow.ThumbsDownAction(context); mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsDownAction.OUTLINE); mRepeatAction = new PlaybackControlsRow.RepeatAction(context); mPipAction = new PlaybackControlsRow.PictureInPictureAction(context); }
Example #4
Source File: VideoMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
private void dispatchAction(Action action) { if (action == mPipAction) { ((Activity) getContext()).enterPictureInPictureMode(); } else { Toast.makeText(getContext(), action.toString(), Toast.LENGTH_SHORT).show(); PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action; multiAction.nextIndex(); notifyActionChanged(multiAction); } }
Example #5
Source File: VideoMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
@Override protected void onPlayCompleted() { super.onPlayCompleted(); mHandler.post(new Runnable() { @Override public void run() { if (mRepeatAction.getIndex() != PlaybackControlsRow.RepeatAction.NONE) { play(); } } }); }
Example #6
Source File: MusicMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { // If either 'Shuffle' or 'Repeat' has been clicked we need to make sure the acitons index // is incremented and the UI updated such that we can display the new state. super.onActionClicked(action); if (action instanceof PlaybackControlsRow.RepeatAction) { int index = ((PlaybackControlsRow.RepeatAction) action).getIndex(); if (mPlaybackService != null) { mPlaybackService.setRepeatState(mapActionIndexToServiceRepeatState(index)); } } }
Example #7
Source File: MusicMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
public static int mapActionIndexToServiceRepeatState(int index) { if (index == PlaybackControlsRow.RepeatAction.ONE) { return MusicPlaybackService.MEDIA_ACTION_REPEAT_ONE; } else if (index == PlaybackControlsRow.RepeatAction.ALL) { return MusicPlaybackService.MEDIA_ACTION_REPEAT_ALL; } else { return MusicPlaybackService.MEDIA_ACTION_NO_REPEAT; } }
Example #8
Source File: MusicMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
public static int mapServiceRepeatStateToActionIndex(int serviceRepeatState) { if (serviceRepeatState == MusicPlaybackService.MEDIA_ACTION_REPEAT_ONE) { return PlaybackControlsRow.RepeatAction.ONE; } else if (serviceRepeatState == MusicPlaybackService.MEDIA_ACTION_REPEAT_ALL) { return PlaybackControlsRow.RepeatAction.ALL; } else { return PlaybackControlsRow.RepeatAction.NONE; } }
Example #9
Source File: MediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
public MediaPlayerGlue(Context context) { super(context, new int[]{1}); mShuffleAction = new PlaybackControlsRow.ShuffleAction(getContext()); mRepeatAction = new PlaybackControlsRow.RepeatAction(getContext()); mThumbsDownAction = new PlaybackControlsRow.ThumbsDownAction(getContext()); mThumbsUpAction = new PlaybackControlsRow.ThumbsUpAction(getContext()); mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); }
Example #10
Source File: MediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { if (action instanceof PlaybackControlsRow.ShuffleAction || action instanceof PlaybackControlsRow.RepeatAction) { ((PlaybackControlsRow.MultiAction) action).nextIndex(); notifySecondaryActionChanged(action); } else if (action == mThumbsUpAction) { if (mThumbsUpAction.getIndex() == PlaybackControlsRow.ThumbsAction.SOLID) { mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsUpAction); } else { mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.SOLID); mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsUpAction); notifySecondaryActionChanged(mThumbsDownAction); } } else if (action == mThumbsDownAction) { if (mThumbsDownAction.getIndex() == PlaybackControlsRow.ThumbsAction.SOLID) { mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsDownAction); } else { mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.SOLID); mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsUpAction); notifySecondaryActionChanged(mThumbsDownAction); } } else { super.onActionClicked(action); } }
Example #11
Source File: VideoConsumptionExampleFragment.java From leanback-showcase with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMediaPlayerGlue = new VideoMediaPlayerGlue(getActivity(), new MediaPlayerAdapter(getActivity())); mMediaPlayerGlue.setHost(mHost); AudioManager audioManager = (AudioManager) getActivity() .getSystemService(Context.AUDIO_SERVICE); if (audioManager.requestAudioFocus(mOnAudioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN) != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { Log.w(TAG, "video player cannot obtain audio focus!"); } mMediaPlayerGlue.setMode(PlaybackControlsRow.RepeatAction.NONE); MediaMetaData intentMetaData = getActivity().getIntent().getParcelableExtra( VideoExampleActivity.TAG); if (intentMetaData != null) { mMediaPlayerGlue.setTitle(intentMetaData.getMediaTitle()); mMediaPlayerGlue.setSubtitle(intentMetaData.getMediaArtistName()); mMediaPlayerGlue.getPlayerAdapter().setDataSource( Uri.parse(intentMetaData.getMediaSourcePath())); } else { mMediaPlayerGlue.setTitle("Diving with Sharks"); mMediaPlayerGlue.setSubtitle("A Googler"); mMediaPlayerGlue.getPlayerAdapter().setDataSource(Uri.parse(URL)); } PlaybackSeekDiskDataProvider.setDemoSeekProvider(mMediaPlayerGlue); playWhenReady(mMediaPlayerGlue); setBackgroundType(BG_LIGHT); }
Example #12
Source File: VideoConsumptionExampleWithExoPlayerFragment.java From leanback-showcase with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExoPlayerAdapter playerAdapter = new ExoPlayerAdapter(getActivity()); playerAdapter.setAudioStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE); mMediaPlayerGlue = new VideoMediaPlayerGlue(getActivity(), playerAdapter); mMediaPlayerGlue.setHost(mHost); AudioManager audioManager = (AudioManager) getActivity() .getSystemService(Context.AUDIO_SERVICE); if (audioManager.requestAudioFocus(mOnAudioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN) != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { Log.w(TAG, "video player cannot obtain audio focus!"); } mMediaPlayerGlue.setMode(PlaybackControlsRow.RepeatAction.NONE); MediaMetaData intentMetaData = getActivity().getIntent().getParcelableExtra( VideoExampleActivity.TAG); if (intentMetaData != null) { mMediaPlayerGlue.setTitle(intentMetaData.getMediaTitle()); mMediaPlayerGlue.setSubtitle(intentMetaData.getMediaArtistName()); mMediaPlayerGlue.getPlayerAdapter().setDataSource( Uri.parse(intentMetaData.getMediaSourcePath())); } else { mMediaPlayerGlue.setTitle("Diving with Sharks"); mMediaPlayerGlue.setSubtitle("A Googler"); mMediaPlayerGlue.getPlayerAdapter().setDataSource(Uri.parse(URL)); } PlaybackSeekDiskDataProvider.setDemoSeekProvider(mMediaPlayerGlue); playWhenReady(mMediaPlayerGlue); setBackgroundType(BG_LIGHT); }
Example #13
Source File: PlaybackOverlayFragment.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public void onActionClicked(Action action) { if (action.getId() == mPlayPauseAction.getId()) { if (mPlayPauseAction.getIndex() == PlayPauseAction.PLAY) { startProgressAutomation(); setFadingEnabled(true); mCallback.onFragmentPlayPause(mVideo, mPlaybackControlsRow.getCurrentTime(), true); } else { stopProgressAutomation(); setFadingEnabled(false); mCallback.onFragmentPlayPause(mVideo, mPlaybackControlsRow.getCurrentTime(), false); } } else if (action.getId() == mSkipNextAction.getId()) { next(); } else if (action.getId() == mSkipPreviousAction.getId()) { prev(); } else if (action.getId() == mFastForwardAction.getId()) { fastForward(); } else if (action.getId() == mRewindAction.getId()) { fastRewind(); } if (action instanceof PlaybackControlsRow.MultiAction) { ((PlaybackControlsRow.MultiAction) action).nextIndex(); notifyChanged(action); } }
Example #14
Source File: PlaybackOverlayFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
public PicassoPlaybackControlsRowTarget(PlaybackControlsRow playbackControlsRow) { mPlaybackControlsRow = playbackControlsRow; }