Skip to content

6. Toro Extended

Nam Nguyen Hoai edited this page Oct 23, 2016 · 2 revisions

Understand the "im.ene.toro2:toro-extended:2.1.0"

What is extended

  • Default ToroPlayer lacks of a few APIs that is not easy to apply generally, so I decided to extend it, with a new concept of Target, which define the "Next one to play" from current Player. See ExtToroPlayer for more information.

  • To help supporting this concept, a new extension is built, on top of ExoPlayer 2 Extension. Signification extension is:

    • Support the target of THIS_PLAYER: a Looping playback behaviour.
    • Support the target of NEXT_PLAYER: automatically smoothly scroll to (if need) next Playable ViewHolder to trigger its playback. This is an Alpha experiment, and used best in a Single Column LinearLayoutManager (i.e not a GridLayoutManager). Please use this carefully.
    • Currently PREV_PLAYER is also defined, but there is no implementation for it. It will require more time.
    • One improvement in this extension is that, the LinearLayoutManager is customized to be able to scroll and snap the ViewHolder to the top of RecyclerView (normal call will stop the View at the bottom).
    • To apply the Target, user need to override ExtToroPlayer#getNextTarget() to provide expected Target. For example returning Target.THIS_PLAYER will result in the looping playback.
  • Another extension is the long click/press event handling. In Toro v1, I already support it inside the ToroPlayer. It turns out that my old implementation is not stable and it is too complicated. I'm not so confident with its stability, so I decided to recreate it.

From now, user can just extend the built-in ExtVideoViewHolder to have the support for Target Player concept. And by calling ExtVideoViewHolder#setOnItemLongClickListener(View.OnLongClickListener), the long click/press event is supported.

See Extended Toro Sample for more information.