# compose

Halil Ozercan

08/25/2020, 2:50 PM
Lately, I've been trying to implement a reddit client in compose. The first challenge I wanted to take on was to play gifs and videos in a list. Notoriously Recyclerview that present video content has been a difficult problem. However, I thought compose would be different based on the experience from my first Youtube like Video Player project. This required a lot more optimization than I initially anticipated but I think this is close to something usable 🙂
👍 4
❤️ 2


08/25/2020, 3:34 PM
can you talk about the optimizations that it required?

Halil Ozercan

08/25/2020, 4:10 PM
Most of these are not optimizations but instead weird implementation details to achieve what I wanted. Sorry if there was a confusion. First of all I started with the video player that I created for my previous project. While designing it, there was no requirement for it to be constantly disposed and recreated. That's why I needed to make adjustments on that end.
didn't work as I expected. I assumed it was going to hold on to the state as long as the composition didn't change order. However,
items are not able to preserve their state by using
, maybe I did something wrong? If I were to directly put
composable in each item, it produced a high amount of lag. Scrolling dropped the FPS to almost 1~2. Instead, I had to use
to delay the actual composition while adding a placeholder with the same size. Also ExoPlayer used a lot of memory initially, so I had many experiments to solve that but it isn't really related to Compose. Since
still does not share its scroll state, I had to use
to understand which item entered the view or left. I don't think it is the best option but it helped me to write a
to manage which video should be played at any given scroll state.

Andrey Kulikov

08/25/2020, 4:18 PM
rememberSavedInstanceState persistence in LazyColumnFor is not yet ready, but is planned

Halil Ozercan

08/25/2020, 4:20 PM
@Andrey Kulikov that's good to know 👍