nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS

Home Page:http://www.charcoaldesign.co.uk/source/cocoa#icarousel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Icarousel media type

Jonbstorey opened this issue · comments

Hi I am currently using the slider to display photos. Is it possible to also add videos into the slider and auto play them?

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
       }