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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
380
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
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.9k
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
120
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
7
1.9k
Agents on Rails - Rails at Scale 2026
irinanazarova
0
340
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
130
FreeBSDでZabbixを動かす
kenkino
0
360
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
350
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
150
Webの地図
yosuke_furukawa
PRO
6
5.1k
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
350
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
140
phperだってパンチカードでコーディングしたい
o0h
PRO
0
210
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
330
How to Ace a Technical Interview
jacobian
280
24k
GitHub's CSS Performance
jonrohan
1033
470k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
700
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
KATA
mclloyd
PRO
35
16k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
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