The Kohii Library

Kohii tutorials

This tutorial shows you how to use Kohii to enable Video playback in a RecyclerView, including automatic start/pause playbacks, recycling playback resources to reduce the memory usage and improve the performance.

Source code

Objective

The Application we are about to build will:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/87f66557-bd43-4330-9532-cb2d4fbc6881/kohii_tut_201_3.webm

Requirement

It is suggested to finish the previous tutorial first. Also you need to be familiar with the RecyclerView at basic level.

Hands-on

We will start with what has been done after the step 1 of this tutorial.

Step 1: Adding RecyclerView

We will need to add RecyclerView dependency, and use it in our layout file. This step has nothing to do with Kohii yet, but a important starting step. You can find the change here:

Step 2: Adding data definition and more RecyclerView implementations

In this step, we add more details about the implementation. In reality, you will have your own data source with many different Videos. In this step, we will just reuse a Video file for all data items. Also to make it close to real life scenario, I will use the AndroidX Lifecycle library in the code:

Below is our App after the step 2: