Class SubtitleView

    • Constructor Detail

      • SubtitleView

        public SubtitleView​(Context context)
    • Method Detail

      • onCues

        public void onCues​(List<Cue> cues)
        Description copied from interface: Player.Listener
        Called when there is a change in the Cues.

        cues is in ascending order of priority. If any of the cue boxes overlap when displayed, the Cue nearer the end of the list should be shown on top.

        Player.Listener.onEvents(Player, Events) will also be called to report this event along with other events that happen in the same Looper message queue iteration.

        Specified by:
        onCues in interface Player.Listener
        Parameters:
        cues - The Cues. May be empty.
      • setCues

        public void setCues​(@Nullable
                            List<Cue> cues)
        Sets the cues to be displayed by the view.
        Parameters:
        cues - The cues to display, or null to clear the cues.
      • setViewType

        public void setViewType​(@com.google.android.exoplayer2.ui.SubtitleView.ViewType int viewType)
        Sets the type of View used to display subtitles.

        NOTE: VIEW_TYPE_WEB is currently very experimental, and doesn't support most styling and layout properties of Cue.

        Parameters:
        viewType - The SubtitleView.ViewType to use.
      • setFixedTextSize

        public void setFixedTextSize​(@Dimension
                                     int unit,
                                     float size)
        Sets the text size to a given unit and value.

        See TypedValue for the possible dimension units.

        Parameters:
        unit - The desired dimension unit.
        size - The desired size in the given units.
      • setUserDefaultTextSize

        public void setUserDefaultTextSize()
        Sets the text size based on CaptioningManager.getFontScale() if CaptioningManager is available and enabled.

        Otherwise (and always before API level 19) uses a default font scale of 1.0.

      • setFractionalTextSize

        public void setFractionalTextSize​(float fractionOfHeight)
        Sets the text size to be a fraction of the view's remaining height after its top and bottom padding have been subtracted.

        Equivalent to #setFractionalTextSize(fractionOfHeight, false).

        Parameters:
        fractionOfHeight - A fraction between 0 and 1.
      • setFractionalTextSize

        public void setFractionalTextSize​(float fractionOfHeight,
                                          boolean ignorePadding)
        Sets the text size to be a fraction of the height of this view.
        Parameters:
        fractionOfHeight - A fraction between 0 and 1.
        ignorePadding - Set to true if fractionOfHeight should be interpreted as a fraction of this view's height ignoring any top and bottom padding. Set to false if fractionOfHeight should be interpreted as a fraction of this view's remaining height after the top and bottom padding has been subtracted.
      • setApplyEmbeddedStyles

        public void setApplyEmbeddedStyles​(boolean applyEmbeddedStyles)
        Sets whether styling embedded within the cues should be applied. Enabled by default. Overrides any setting made with setApplyEmbeddedFontSizes(boolean).
        Parameters:
        applyEmbeddedStyles - Whether styling embedded within the cues should be applied.
      • setApplyEmbeddedFontSizes

        public void setApplyEmbeddedFontSizes​(boolean applyEmbeddedFontSizes)
        Sets whether font sizes embedded within the cues should be applied. Enabled by default. Only takes effect if setApplyEmbeddedStyles(boolean) is set to true.
        Parameters:
        applyEmbeddedFontSizes - Whether font sizes embedded within the cues should be applied.
      • setStyle

        public void setStyle​(CaptionStyleCompat style)
        Sets the caption style.
        Parameters:
        style - A style for the view.
      • setBottomPaddingFraction

        public void setBottomPaddingFraction​(float bottomPaddingFraction)
        Sets the bottom padding fraction to apply when Cue.line is Cue.DIMEN_UNSET, as a fraction of the view's remaining height after its top and bottom padding have been subtracted.

        Note that this padding is applied in addition to any standard view padding.

        Parameters:
        bottomPaddingFraction - The bottom padding fraction.