Video-Player-RecyclerView icon indicating copy to clipboard operation
Video-Player-RecyclerView copied to clipboard

When list loaded first video not play

Open mrj976 opened this issue 6 years ago • 2 comments

Thank you I have problem When list loaded first video not play and when i scroll list first video playing I want when list loaded first video play without scroll list Please help me Thanks

mrj976 avatar Dec 07 '19 08:12 mrj976

Im with the same problem.

How can we play the first video when list loaded?

Thanks.

paulocoutinhox avatar Apr 09 '21 18:04 paulocoutinhox

I made a solution:

Inside your RecyclerView class create the method:

fun checkToPlayVideo() {
    if (canScrollVertically(1)) {
        playVideo(false)
    } else {
        playVideo(true)
    }
}

And when you set RecyclerView "items" you need call:

private fun updateList() {
    list?.layoutManager = createLayoutManager()
    list?.setListObjects(listData ?: ArrayList())
    list?.adapter = adapter
    list?.setHasFixedSize(true)

    Handler().postDelayed({
        list?.checkToPlayVideo()
    }, 200)
}

Thanks.

paulocoutinhox avatar Apr 09 '21 19:04 paulocoutinhox