Custom played colour in TimeBar
Hey guys!
Just updated to 2.4.0 and am playing around with the new TimeBar. Loving the customisations available.
I set a custom playedColor (app:played_color="@color/red"), and noticed that the colour of the whole progress bar changes to the played colour when scrubbing finishes. So if I'm at position 1000 and am scrubbing back to position 200, the played colour only fills up to 200, but if I let go at 200, the whole bar turns to the played colour.
The name played_color is misleading. The value is used as the bar color both to the left and to the right of the scrubbing handle, except that the opacity is overridden to be opaque for the part of the bar on the left of the handle.
You should be able to see this if you set the color like app:played_color="#880000FF". In this case the section of the bar to the left of the handle should be opaque blue while the section to the right should be translucent. (The other relevant color, which can also be overridden, is the buffered_color; if you saw a different color to the right of the scrubbing handle, that might be due to the player having buffered past the playback position, and possibly to the end of the content.)
I'll fix the naming of the attribute, but I suspect you might also want the ability to set the colors to the left and the right of the scrubbing handle separately? Please clarify if this is the case and if so I'll mark this as an enhancement. Thanks!
Thank you for your response and explanation, Andrew!
Okay, so my app:played_colour was #EA4239, and that colour was applied both left and right of the playhead, without any opacity change. When I changed the colour to #88EA4239, the opacity is correctly set, and the left side is different to the right side. I guess the colour is incorrectly parsed if there's no alpha value?
Also, something that I found odd: when scrubbing back, the buffered colour is used instead of the played colour. So we get a section of solid red, the playhead, buffered colour up to currentPosition, followed by translucent red. When scrubbing finishes, the bar turns translucent red to the right of the playhead. I personally think that the buffered colour shouldn't show when scrubbing back, as that section isn't technically buffered, and just results in a colour jump. What are your thoughts on this?
I suspect #EA4239 is implicitly opaque. The color is used unmodified on the unplayed portion, and is made opaque for the played portion, and in this case there's no difference because the color is already opaque.
I'll mark this as an enhancement to track being able to specify colors for the played/buffered/unplayed parts of the bar and the scrubber handle separately.
If you want to customize how the buffered section is shown, you can make your own implementation of TimeBar and use it with PlaybackControlView.