Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Some thought about Video playback on RecyclerView

Some thought about Video playback on RecyclerView

Talk about problem/solution, focusing on a modern UI/UX concept where list view contains various type of content, and each of them need to response to the User behaviour.

Nam Nguyen Hoai

October 25, 2017
Tweet

More Decks by Nam Nguyen Hoai

Other Decks in Programming

Transcript

  1. About me Nguyen Hoai Nam (ナム) • :SBクラウド* • Github:eneim

    • Twitter:ene__im • Lang:vi, en, jp, java, js, kotlin • Android:by hobby & OSS contributor, interested in performance, proof of concept, ... * Cloud Engineer
  2. Modern UI/UX: rich, responsive • List contains various types of

    content, including Text, Video, Gif, Image, … ◦ Eg: Facebook frontpage, Twitter timeline, Instagram, etc • Responsive to User’s scroll ◦ Auto playback start/pause, animation, etc. → Want to create one? the problems: ◦ 1. No obvious/official solution. ◦ 2. Existing solutions may not so easy to use. ◦ 3. Existing solutions may not well respect the Lifecycle.
  3. How to: a brainstorming • No obvious/official solution → Create

    one • Existing solutions are not easy to use → Create one easy to use ◦ Easy to use = less effort to integrate, maintain, scale, test . • Existing solutions do not respect the Lifecycle → Create one that does ◦ Respect the Lifecycle = ? → TBD ◦ Lifecycle is not everything → Respect the Lifecycle on Demand (Customizable)
  4. Problem: the Lifecycle Created Destroyed Attached to Window Detached from

    Window View’s lifecycle review Lives a complicated Life System Interactions User Interactions Self Behaviours
  5. Problem: the Lifecycle + α • Configuration Changes (Recreation) ◦

    Window size change ◦ Orientation change ◦ ... • UI behaviour Changes (Non Recreation) ◦ Visibility change ◦ Focus change ◦ Scroll state change ◦ ... • Others changes made by User ◦ Network status change ◦ Permission change ◦ ... • Anything else ◦ Device spec ◦ OS spec ◦ Business level spec ◦ Player APIs
  6. Toro v3: a proposal ➔ ✅ Solve the minimum problem

    ◆ Responsive to User scroll, auto start/pause. ➔ ✅ Respect stuff on demand ◆ Respect to the Lifecycle, respect to UI change, etc ➔ ✅ Easy to use ◆ Easy as write an xml + a Custom ViewHolder. ◆ Complicated setup is backed by a rich feature Demo App (= Copy/Paste ready). ◆ Advanced usage ready (also Copy/Paste ready by Demo App) ➔ ❎ Testable → Not yet ◆ 4.x+ or maybe 5.x+ ...
  7. How Toro solves the problems? • Container (extends RecyclerView) ◦

    Hook into important events with care: ▪ State save/restore ▪ Window visibility change ▪ Child attach/detach • PlayerSelector ◦ Flexible playback selection • ToroPlayer ◦ Playback interface ◦ Straightforward implementation ◦ Rich feature Demo, Copy&Paste Ready • CacheManager ◦ Control playback state save/restore ◦ Optional, On Demand • ToroLayoutManager ◦ Interface for custom LayoutManager to follow • Copy&Paste ready ◦ Rich feature Demo App, Youtube included • Player API: ExoPlayer 2 ready (helpers)
  8. Appendix • How to create Screen record with Device Frame?

    ◦ https://paul.kinlan.me/android-screen-recording-and-device-framing/ ◦ https://gist.github.com/eneim/d30952c2f6544a75c56a1791b01f81ac • A brief introduction into Toro ◦ https://eneim.github.io/2017/07/09/toro-101-how-to-1/