Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AVPlayer周りの設計tips

toshi0383
October 09, 2018

 AVPlayer周りの設計tips

potatotips #55 の発表資料です。

toshi0383

October 09, 2018
Tweet

More Decks by toshi0383

Other Decks in Programming

Transcript

  1. ҰൠతʹΑ͘ݟΔίʔυ class ViewController: UIViewController { var player: AVPlayer? ... override

    func viewDidLoad() { super.viewDidLoad() player?.play() } } © Toshihiro Suzuki 2018 11
  2. RxSwift // ViewModel let control = VideoPlayerControl() ... requestReload .startWith(())

    // NOTE: initial load .subscribe(onNext: { [weak self] in guard let me = self else { return } me.manager = VideoPlayerManager(url: me.url, control: me.control) me.manager.player.asObservable() .bind(to: me.playerRelay) .disposed(by: me.manager.playerDisposeBag) }) .disposed(by: disposeBag) © Toshihiro Suzuki 2018 20
  3. RxSwift // ViewController viewModel.playerRelay.asObservable() .observeOn(ConcurrentMainScheduler.instance) .subscribe(onNext: { [weak self] player

    in self?.playerView.playerLayer.player = player }) .disposed(by: disposeBag) © Toshihiro Suzuki 2018 21