Icarousel media type
Jonbstorey opened this issue · comments
Jonathan B. Storey commented
Hi I am currently using the slider to display photos. Is it possible to also add videos into the slider and auto play them?
Turacbey commented
Yes it is. On func called func carousel(_ carousel: iCarousel, viewForItemAt index: Int, reusing view: UIView?) -> UIView
UIView is returned. So, you can simply add what you want to view and show them on slider..
For example;
func carousel(_ carousel: iCarousel, viewForItemAt index: Int, reusing view: UIView?) -> UIView {
let view = UIView()
view.frame = icroulsel.frame
player = AVPlayer(url: ETC)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.videoGravity = .resizeAspectFill
playerLayer.frame = self.icroulsel.bounds
view.layer.insertSublayer(playerLayer, at: 0)
return view
}