简体   繁体   中英

How to use ViewPager slideshow images and videos with different slide time duration in android?

I am looking for a solution to create a slider show in android. I want to mix the video and image with it with different time duration like each item having own time duration like 10 secs or 20 secs. I only found how to create a image only slider show.

You can register OnPageChangeCallback and on every onPageSelected(psoition: Int) you can check for the position < adapter.itemCount and use viewPager.currentItem = position + 1 or viewPager.currentItem = 0 when you have reached the last item.

For the CountDownTimer you can use the time whatever you want like you can hard code it to 20 sec or you can use adapter to get the current item, check for the type, fetch the video duration with the MediaMetadataRetriever class. Do whatever fits your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM