Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
AVPlayer周りの設計tips
Search
toshi0383
October 09, 2018
Programming
940
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AVPlayer周りの設計tips
potatotips #55 の発表資料です。
toshi0383
October 09, 2018
More Decks by toshi0383
See All by toshi0383
CoreDataはじめました
toshi0383
0
190
Swiftコードバトル必勝法
toshi0383
1
370
Sheets API使ってみた
toshi0383
2
430
visionOSについてGlobeeが取り組んでいること
toshi0383
0
620
agile20150512-150512055145-lva1-app6892.pdf
toshi0383
0
270
たのしいAirPlay
toshi0383
1
810
Profiling using Signpost
toshi0383
2
1.1k
cmdshelf::from("Swift")
toshi0383
3
950
AbemaTV iOSのダウンロード再生機能
toshi0383
4
1k
Other Decks in Programming
See All in Programming
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
570
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.6k
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
430
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
19
20k
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
230
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
4
450
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
270
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
370
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
650
Featured
See All Featured
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
380
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
910
Design in an AI World
tapps
1
340
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
590
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Raft: Consensus for Rubyists
vanstee
142
7.7k
Navigating Team Friction
lara
192
16k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
410
Transcript
AVPlayerपΓͷઃܭtips potatotips #55 Oct 9, 2018 Toshihiro Suzuki © Toshihiro
Suzuki 2018 1
whoami @toshi0383 (Toshihiro Suzuki) ಡΈํ: τογʔ or... © Toshihiro Suzuki
2018 2
ʮ౦ژ࠷ͷஉʯ͞Μ © Toshihiro Suzuki 2018 3
झຯ: ѪंͰυϥΠϒ (ՈͰ) © Toshihiro Suzuki 2018 4
job AbemaTV iOS/tvOS ετΫϥ (Streaming Client Team) ಈը࠶ੜ࣭ © Toshihiro
Suzuki 2018 5
Developer Blog https://developers.cyberagent.co.jp/blog/archives/17579/ © Toshihiro Suzuki 2018 6
ࠓͷςʔϚ © Toshihiro Suzuki 2018 7
AVPlayerपΓͷίʔυΛͲ ͏ཧͨ͠Β͍͍͔ ͋͘·ͰҰྫͳͷͰɺ͝ࢀߟఔʹɻ © Toshihiro Suzuki 2018 8
ྲྀΕ —લఏͱͳΔํ —ઃܭͷશମ૾Λ၆ᛌ © Toshihiro Suzuki 2018 9
ํ —AVPlayerUIͱͯ͠ଊ͑ͳ͍ —replaceCurrentItemΘͳ͍ (লུ) © Toshihiro Suzuki 2018 10
ҰൠతʹΑ͘ݟΔίʔυ class ViewController: UIViewController { var player: AVPlayer? ... override
func viewDidLoad() { super.viewDidLoad() player?.play() } } © Toshihiro Suzuki 2018 11
Α͘ݟΔίʔυͷ —playerΛ৮Δίʔυ͕ࢄΒ͍ͬͯͯݟ௨͕͠Α͘ͳ ͍ —ଞͷView͔Β৮Γ͍ͨ߹ʹڑ͕͋Δ © Toshihiro Suzuki 2018 12
ͦͦϓϨΠϠʔ͔ͩΒͬͯView ʹറΒΕ͍ͯΔͷ͕ѱ͍ͷͰ © Toshihiro Suzuki 2018 13
AVPlayerͷॳظԽૢ࡞ϝΠϯε Ϩουඞਢͱ͍͏ݴ͍͑ ࠷ۙ͋·Γฉ͔ͳ͍͚ͲɺҎલͦ͏͍͏ৗ͕ࣝଘࡏ ͨ͠ؾ͕͢Δɻ © Toshihiro Suzuki 2018 14
໎৴Ͱ͢ ؾͷ͍ͤͳͷͰΕ·͠ΐ͏ © Toshihiro Suzuki 2018 15
ͨͩ͠ KVOͷొϝΠϯεϨουͷํ͕͍͍ͱ͍͏هड़͋Γ https://developer.apple.com/documentation/avfoundation/avplayer © Toshihiro Suzuki 2018 16
͋ͱ ͜͏͍͏͋ΔͷͰཁݕূ https://speakerdeck.com/kyoheig3/abema-devcon?slide=24 © Toshihiro Suzuki 2018 17
ͱ͍͑ɺ ϝΠϯεϨου == UI ʹറΒΕΔඞ ཁͳ͍ͣ Appleͷαϯϓϧ AssetPlaybackManager ͕playerΛཧ͍ͯ͠Δ ͬͱ্ྲྀͰͬͯ͠·͓͏ʂ
© Toshihiro Suzuki 2018 18
၆ᛌΠϥετ © Toshihiro Suzuki 2018 19
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
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
·ͱΊ —AVPlayerੜΛUI͔Βͨ͠Βগ͠εοͱͨ͠ —ManagerΫϥεʹΓग़ͤͨ͜ͱͰɺը໘Λލ͍Ͱ ૢ࡞&ੜଘ͕Մೳ => Picture-in-Pictureͱ͔ෳϓϨΠϠʔͱ͔ —VideoPlayerStream Λ͏͜ͱͰɺϓϨΠϠʔͷ ڍಈΛmockՄೳ. (testable!)
© Toshihiro Suzuki 2018 22
toshi0383/VideoPlayerManager ৭ʑ్தͰ্͕͕ͬͯ͢·͢ɻ https://github.com/toshi0383/VideoPlayerManager Open-Source! © Toshihiro Suzuki 2018 23
ͪͳΈʹ ࣮AbemaTV iOSΞϓϦ͜Ε͔Β͜ͷํͰϦϑΝ ΫλʹऔΓֻ͔Δͱ͜Ζɻ tvOSͱڞ௨Ͱ͑ΔϥΠϒϥϦʹ͍ͨ͠ɻ ·ͩ·ͩࡉ͔͍ͱ͜Ζ͜Ε͔Βߟ͑ΔͷͰɺ͝ҙݟื ूதͰ͢ɻ © Toshihiro Suzuki
2018 24
ͪͳΈʹͪͳΈʹ Ұॹʹಇؒ͘·ͩ·ͩืूதͰ͢ ҰॹʹςετۦಈͰࢹௌମݧ্ ͠·͠ΐ͏ ! © Toshihiro Suzuki 2018 25
͓ΘΓ © Toshihiro Suzuki 2018 26
ࢀߟࢿྉ —Apple AVPlayerυΩϡϝϯτ —AVPlayerϕετϓϥΫςΟε by @KyoheiG3 —ಈըΞϓϦΛͳΊΒ͔ʹಈ͔ٕ͢ज़ by @dekatotoro ©
Toshihiro Suzuki 2018 27
Toshihiro Suzuki ! Twitter/GitHub/GTSport => @toshi0383 Email:
[email protected]
© Toshihiro
Suzuki 2018 28