Add inside instantiateItem to check if extension mp4 then load video:
InstantiateItem:
val itemViewVideo = layoutInflater!!.inflate(R.layout.pager_video, container, false)
val videoView = itemViewVideo.findViewById<VideoView>(R.id.videoView)
then add after view:
val imgType = imageList!![position].imageUrl!!.toString().substringAfterLast('.', "")
if (imgType == "mp4") {
val mediaController = MediaController(itemViewVideo.context)
val vidAddress = imageList!![position].imageUrl.toString()
val vidUri = parse(vidAddress)
videoView.setVideoURI(vidUri);
videoView.setOnPreparedListener(OnPreparedListener { mp ->
mp.setVolume(0f, 0f)
mp.isLooping = true
})
videoView.seekTo(1);
videoView.start();
mediaController.setAnchorView(videoView);
container.addView(itemViewVideo)
return itemViewVideo
}
Take care to change and increase period of time. Also video should run when UI is visible so need to fine tune.
Create pager_video.yml inside layout resource:
Add inside instantiateItem to check if extension mp4 then load video:
InstantiateItem:
then add after view:
Take care to change and increase period of time. Also video should run when UI is visible so need to fine tune.
Hope someone helps.