Video Controls minimum implementation
– Android TV app hands on Tutorial 8

Video Controls minimum implementation

Video is streamed in VideoView.

* I referred Google’s latest sample Android TV application. AOSP sample application implementation is defferent.

For Video controls, we have several stuff to explain.

  1. Action’s UI update part (this chapter)
  2. Video control part (this chapter)
  3. MediaSession implementation, Video control via MediaController’s TransportControls (next chapter)
    – MediaSession can handle the action when user presses TV remote controller’s video control button.
    – It allows other activity to inherite video control. Especially LeanbackLauncher, Home display, can play video in background.  
  4. set MediaMetadata to MediaSession (next chapter)
    – “Now playing card” will appear at the top of recommendation row.

In this chapter, Video controls implementation is explained. Since Google’s sample application implements all 1~4, source code is bit long and difficult to understand for beginners. I did a minimum implementation for only 1~2. I will just explain these implementation for each part in this chapter, so please download & refer source code on github at first (I did a refactoring for using MovieProvider class to prepare movie contents). The Technic in this chapter is general in Android.

Next chapter I will explain about MediaSession implementation. We can pass VideoView control to LeanbackLauncher by using MediaSession, which results to achieve playing video background in LeanbackLauncher. 

VideoView handling 

PlaybackOverlayActivity need to have VideoView field variable “mVideoView” to control video.


Implement setOnActionClickedListener & onActionClicked callback 

To assign action of each video control button, we use setOnActionClickedListener which is a method of PlaybackControlsRowPresenter.

From here, Each action’s implementation is explained. Note that it is important to differentiate “UI update part” and “Video control part”, because Video control part will move to MediaSession in next chapter.

In the source code, I implemented “UI update part” in, while “Video control part” is implemented in


Video control part will handle play/pause video in VideoView.

UI control part will handle 

  • Toggling icon of Play/Pause
  • Update current time of video


Rewind & FastForward

Here, rewind & fast forward Video control implementations are done in easy way, just rewind/fast forward 10 seconds from current position.

UI control part is updating current time of video.

SkipPrevious & SkipNext

For Video control part, 2 functions are doing same thing except for first line. mCurrentItem is set to previous/next followed by setting proper video path by using setVideoPath method & play/pause depending on current play/pause status by using playPause method.

UI control part, first line calls playbackStateChanged() method, but it is only necessary to control startProgressAutomation/stopProgressAutomation to update current time status of video. updateplaybackRow method is to update DetailsDescription information of video content.


ThumbUp & ThumbDown & Repeat & Shuffle & HighQuality & ClosedCaptioning & MoreActions

How to toggle icon’s color? You can change by setting index of the action. Implement below in onActionClicked method to check how each index setting will behave.


Action icon change in SecondaryActionsAdapter.


Build & Run

Now you can check that Video control is working correctly for PrimaryRow.
*SecondaryRow’s action implementation may differ depending on your desire and I will skip here.

* Note. I could take VideoView’s image by screen recording, but I couldn’t take VideoView’s screen capture via Android studio’s debugging tool… (I’m using Sony Android TV for development of Android TV now.)

Again source code is on github.

Next chapter, we implement MediaSession.

Sponsored Links

19 responses

  1. Hi, thank you for these tutorials.
    Wanted to know if you ever solved video scale (zoom) task on Android TV? VideoView does not have these features… I’m trying to make something like “ORIGINAL”, “STRETCH”, “FILL” video modes. No luck yet…

  2. Hi,
    I was trying to implement this menu with exo player but with no luck at all 🙁 Could you give me a little lead how would you do it ? I have problem with layouting since exo player needs to have subbtitle layout etc.

  3. There is small bug in PlaybackOverlayFragment. When you click on action in secondary row its ignored for first time. Its caused because notifyChanged(action); is called before ((PlaybackControlsRow.MultiAction) action).nextIndex();
    It can be fixed simply by moving notifyChanged(action); under if statement like this :

    if (action instanceof PlaybackControlsRow.ThumbsUpAction ||
    action instanceof PlaybackControlsRow.ThumbsDownAction ||
    action instanceof PlaybackControlsRow.RepeatAction ||
    action instanceof PlaybackControlsRow.ShuffleAction ||
    action instanceof PlaybackControlsRow.HighQualityAction ||
    action instanceof PlaybackControlsRow.ClosedCaptioningAction) {
    ((PlaybackControlsRow.MultiAction) action).nextIndex();

  4. HI,

    I have been regularly following you blog, and would like to thank you for posting and knowledge sharing.

    I am trying to create a streaming application using the Leanback library for the android (Kitkat Verison) STB. The chipset is AMlogic S805. I tweaked a little in the gradle with the minSDkverison and TargetVerison and the Leanback UI is supported, the DetailActivity, PlaybackOverlay etc is working fine. The only problem is with the Player. I tried to use your sample app on the device and found that it doesnt support the playback. However I was able to play it on the AndroidTV. Can you suggest any tweaks that can be done in order to play the video for the Kitkat version. I mean if any other player you would recommed to be used.

    Thanks again for sharing your knowledge.

  5. Hi,

    Any idea how to do continuous seeking on pressing of forward and rewind button rather than just jumping for a fixed time.

Leave a Reply

Your email address will not be published.