Java Code Examples for com.google.android.exoplayer2.util.Util#getStringForTime()

The following examples show how to use com.google.android.exoplayer2.util.Util#getStringForTime() . 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: ExoVideoPlaybackControlView.java    From ExoVideoView with Apache License 2.0 6 votes vote down vote up
private CharSequence generateFastForwardOrRewindTxt(long changingTime) {

        long duration = player == null ? 0 : player.getDuration();
        String result = Util.getStringForTime(formatBuilder, formatter, changingTime);
        result = result + "/";
        result = result + Util.getStringForTime(formatBuilder, formatter, duration);

        int index = result.indexOf("/");

        SpannableString spannableString = new SpannableString(result);


        TypedValue typedValue = new TypedValue();
        TypedArray a = getContext().obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorAccent});
        int color = a.getColor(0, 0);
        a.recycle();
        spannableString.setSpan(new ForegroundColorSpan(color), 0, index, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        spannableString.setSpan(new ForegroundColorSpan(Color.WHITE), index, result.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        return spannableString;
    }
 
Example 2
Source File: DefaultTimeBar.java    From tysq-android with GNU General Public License v3.0 4 votes vote down vote up
private String getProgressText() {
    return Util.getStringForTime(formatBuilder, formatter, position);
}