support Contact Support | system status System Status
Page Contents

    Customizing Android TV Controls

    In this topic, you will learn how to customize the rewind and fast-forward buttons for Android TV.

    Introduction

    The Brightcove Media Controller for TV has a rewind button and a fast-forward button. When you click either of these buttons, the default is to seek 3 seconds backward or forward.

    When you press and hold either button, the seek position will update at a rate of 3 seconds of content every 40 milliseconds. This means that holding either the rewind or fast-forward button each second advances the cotent 75 seconds.

    Configuring seek buttons

    The rewind and fast-forward buttons can be configured through the EventType.SEEK_CONTROLLER_CONFIGURATION event.

    For simplicity, we’ll refer to either of these buttons as the seek button since the following properties apply to both.

    Event property Default value Description
    Event.SEEK_DEFAULT 3000 ms The default seek value in milliseconds the seek button will seek to.
    Event.SEEK_RELATIVE_ENABLED false If enabled, allows the seek value to be relative to the video duration set by the EventType.VIDEO_DURATION_CHANGED event. The percentage is set by Event.SEEK_PERCENTAGE.
    Event.SEEK_PERCENTAGE 1% The percentage relative to the video duration used to calculate the default seek value.
    Event.SEEK_ON_HOLD_WAIT_TIME 500 ms The time in milliseconds to be waited for the key event to be considered a long press instead of a regular press.
    Event.SEEK_ON_HOLD_UPDATE_FREQ 40 ms The time in milliseconds used to send the EventType.SEEKBAR_DRAGGING_PROGRESS event to update the Media Controller seek bar.

    Customizing event properties

    You may want additional event properties from those listed in the table above. You can do that by defining the expected values and emitting the EventType.SEEK_CONTROLLER_CONFIGURATION event.

    To add custom properties to the event, follow these steps:

    1. Define your custom values.

      private static final int DEFAULT_TV_SEEK_TIME = (int) TimeUnit.SECONDS.toMillis(3);
      private static final int DEFAULT_TV_ON_HOLD_WAIT_TIME = (int) TimeUnit.SECONDS.toMillis(1);
      private static final int DEFAULT_TV_SEEK_PERCENTAGE = 1;
      private static final int DEFAULT_TV_ON_HOLD_UPDATE_FREQUENCY_TIME = 500;
      
    2. Include a method to create the properties map, add the desired values and emit the EventType.SEEK_CONTROLLER_CONFIGURATION event.

      private void setupTelevisionMode() {
         Map<String, Object> properties = new HashMap<>();
         properties.put(Event.SEEK_DEFAULT, DEFAULT_TV_SEEK_TIME);
         properties.put(Event.SEEK_RELATIVE_ENABLED, true);
         properties.put(Event.SEEK_PERCENTAGE, DEFAULT_TV_SEEK_PERCENTAGE);
         properties.put(Event.SEEK_ON_HOLD_WAIT_TIME, DEFAULT_TV_ON_HOLD_WAIT_TIME);
         properties.put(Event.SEEK_ON_HOLD_UPDATE_FREQ, DEFAULT_TV_ON_HOLD_UPDATE_FREQUENCY_TIME);
      
         eventEmitter.emit(EventType.SEEK_CONTROLLER_CONFIGURATION, properties);
      }
    3. Check if your app is in TV mode to setup the seek controller configuration.

      if (BrightcoveMediaController.checkTvMode(mBaseVideoView.getContext())) {
         setupTelevisionMode();
      }

    Page last updated on 28 Sep 2020