Slide 1

Slide 1 text

Video playback on RecyclerView: why, how, what? potatotips #44, @eneim

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Warning: ● ライブラリの宣伝あり ● テキストが多い ● ここだけ日本語あり

Slide 4

Slide 4 text

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.

Slide 5

Slide 5 text

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)

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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+ ...

Slide 9

Slide 9 text

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)

Slide 10

Slide 10 text

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/

Slide 11

Slide 11 text

Thanks for listening