MotionInMotion Episode 31 - Custom Video Players and Animating Videos
Custom Video Players and Animating Videos - MotionInMotion
ビデオを再生しながらアニメーション
- PlayerController
- file_url = NSBundle.mainBundle.URLForResource('big_buck_bunny', withExtension: 'mp4')
- file_url = NSURL.URLWithString('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4')
- @player = AVPlayer.playerWithURL(file_url)
- @player_layer = AVPlayerLayer.playerLayerWithPlayer(@player)
- @player_layer.speed = 0.2
- view.layer.addSublayer(@player_layer)
- file_url = NSBundle.mainBundle.URLForResource('big_buck_bunny', withExtension: 'mp4')
- controls
- view.addSubview(@controls = ControlsView.new)
- @controls.play.addTarget(self, action: 'play:', forControlEvents: UIControlEventTouchUpInside)
- play, parse, reset, animate
- reset
- @player.seekToTime(KCMTimeZero)
- @player.play
- animate
- @scaled ||= false
- if !@scaled
- @scaled = !@scaled
- @player_layer.transform = CATransform3DConcat(
- CATransform3DMakeScale(0.5, 0.5, 1),
- CATransform3DMakeTranslation(0, 100, 0)
- @scaled ||= false
- Sample Video