nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
11.99k stars 2.58k forks source link

Icarousel media type #869

Open Jonbstorey opened 5 years ago

Jonbstorey commented 5 years ago

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 5 years ago

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
        }