Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Androidでオーディオアプリを作るということ
Search
rmakiyama
September 26, 2020
Technology
1
3.2k
Androidでオーディオアプリを作るということ
Androidでオーディオアプリを作るときに考慮すべきところなどを簡単に。
rmakiyama
September 26, 2020
Tweet
Share
More Decks by rmakiyama
See All by rmakiyama
KMPプロジェクトでマニュアルDIを使う選択
rmakiyama
0
160
Jetpack Composeとデザインシステム
rmakiyama
0
630
TextField theme in Compose
rmakiyama
0
220
Androidエンジニアが1人という不安と向き合う
rmakiyama
6
6.5k
Jetpack Compose Canvas入門
rmakiyama
0
1.3k
HiltはDIをどうやってやっているのか
rmakiyama
1
220
Radiotalk Androidアプリにおけるモジュール分割の課題とこれから
rmakiyama
1
270
getChangePayload in DiffUtil
rmakiyama
0
2.9k
ContextThemeWrapperでthemeをより賢く
rmakiyama
1
2k
Other Decks in Technology
See All in Technology
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
Lambdaと地方とコミュニティ
miu_crescent
2
370
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.1k
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
Platform Engineering for Software Developers and Architects
syntasso
1
520
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
110
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
Can We Measure Developer Productivity?
ewolff
1
150
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
How to train your dragon (web standard)
notwaldorf
88
5.7k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
GitHub's CSS Performance
jonrohan
1030
460k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Designing for Performance
lara
604
68k
Done Done
chrislema
181
16k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Visualization
eitanlees
145
15k
Transcript
"OESPJEͰ ΦʔσΟΦΞϓϦΛ ࡞Δͱ͍͏͜ͱ Zli x ΤΩαΠτ ߹ಉLT 2020/09/26 ryo makiyama
ɹɹࣗݾհ •ࢁྎ •Radiotalkגࣜձࣾ •AndroidΤϯδχΞ • @_rmakiyama • rmakiyama
ԻΛ࠶ੜ͢Δ
ԻΛ࠶ੜ͢Δʹʁ • AudioTrack • SoundPool • MediaPlayer • ExoPlayer •
etc…
ԻΛ࠶ੜ͢Δʹʁ • AudioTrack • ੜͷԻσʔλΛѻ͑Δ • ࠷Ԇ͕গͳ͍ • ѻ͍͕͍͠… •
SoundPool • ͍Իʹద͍ͯ͠Δ • ޮՌԻͳͲ • ෛՙ͕͍ • Ԇ͕গͳ͍
ԻΛ࠶ੜ͢Δʹʁ • MediaPlayer • ࠷Ұൠత • ө૾ʹରԠ • ѻ͍͕؆୯ •
HLSະରԠ • ExoPlayer • GoogleͷϥΠϒϥϦ • ө૾ʹରԠ • ΧελϚΠζੑ͕ߴ͍ • HLSDASHʹରԠ
ExoPlayer val audioUri = Uri.parse(“https:"//sample.jp/media/media1.mp3”) val player = SimpleExoPlayer.Builder(context).build() val
sourceFactory = DefaultDataSourceFactory( context, Util.getUserAgent(context, "sample") ) val extractorsFactory = DefaultExtractorsFactory() val source = ProgressiveMediaSource.Factory(sourceFactory, extractorsFactory) .createMediaSource(audioUri) player.prepare(source)
؆୯
؆୯
ΦʔσΟΦΞϓϦʹٻΊΒΕΔ͜ͱ • όοΫάϥϯυͰ࠶ੜͰ͖Δ • ΠϠϗϯ͕ൈ͚ͨΒԻ͕ࢭ·Δ • ผͷΞϓϦͰԻΛ࠶ੜ͢Δͱఀࢭ͢Δ • ༷ʑͳσόΠε͔Βૢ࡞͕Ͱ͖Δ •
etc…
Ͳ͏ͬͯͬͯΔͷ
ΦʔσΟΦΞϓϦʹٻΊΒΕΔ͜ͱ • όοΫάϥϯυͰ࠶ੜͰ͖Δ • ΠϠϗϯ͕ൈ͚ͨΒԻ͕ࢭ·Δ • ผͷΞϓϦͰԻΛ࠶ੜ͢Δͱఀࢭ͢Δ • ༷ʑͳσόΠε͔Βૢ࡞͕Ͱ͖Δ •
etc… AndroidͷServiceΛར༻͢Δ
ΦʔσΟΦΞϓϦʹٻΊΒΕΔ͜ͱ • όοΫάϥϯυͰ࠶ੜͰ͖Δ • ΠϠϗϯ͕ൈ͚ͨΒԻ͕ࢭ·Δ • ผͷΞϓϦͰԻΛ࠶ੜ͢Δͱఀࢭ͢Δ • ༷ʑͳσόΠε͔Βૢ࡞͕Ͱ͖Δ •
etc… ExoPlayerઌੜ͕ͬͯ͘ΕΔ
ΦʔσΟΦΞϓϦʹٻΊΒΕΔ͜ͱ • όοΫάϥϯυͰ࠶ੜͰ͖Δ • ΠϠϗϯ͕ൈ͚ͨΒԻ͕ࢭ·Δ • ผͷΞϓϦͰԻΛ࠶ੜ͢Δͱఀࢭ͢Δ • ༷ʑͳσόΠε͔Βૢ࡞͕Ͱ͖Δ •
etc…
headset watch tv auto
༷ʑͳσόΠε͔Β ૢ࡞͞ΕΔ͜ͱΛ ఆ͢Δඞཁ͕͋Δ
ΦʔσΟΦΞϓϦͷਪΞʔΩςΫνϟ • ΫϥΠΞϯτ/αʔόʔઃܭ • ϝσΟΞίϯτϩʔϥʔ(ΫϥΠΞϯτ) • ϝσΟΞηογϣϯ(αʔόʔ) • UIʹΑΔૢ࡞ͱ ίϯςϯπใɾϓϨΠϠʔૢ࡞Λ͚ͨ
ref. https:"//developer.android.com/guide/topics/media-apps/media-apps-overview
UI/ϝσΟΞίϯτϩʔϥʔ(ΫϥΠΞϯτ) • UIίϯτϩʔϥʔͷΈͱΓͱΓ • ϓϨΠϠʔࣗମͱΓऔΓΛ͠ͳ͍ • ΞΫγϣϯηογϣϯͷίʔϧόοΫʹ • ۂใͷมߋͳͲηογϣϯ͔Β ίϯτϩʔϥʔ͕ίʔϧόοΫܗࣜͰड͚औΔ
ϝσΟΞηογϣϯ/ϓϨΠϠʔ(αʔόʔ) • 1ͭͷηογϣϯͰෳͷίϯτϩʔϥʔ͔Β ίʔϧόοΫΛड͚Δ͜ͱ͕Ͱ͖Δ • ϓϨΠϠʔηογϣϯ͔ΒͷΈૢ࡞͞ΕΔ • ίϯτϩʔϥʔ͔ΒͷίʔϧόοΫʹΑΓૢ࡞
ΦʔσΟΦΞϓϦ֓ཁ ref. https:"//developer.android.com/guide/topics/media-apps/media-apps-overview controller session player ui devices/controller
࣮ฤ%
ΦʔσΟΦΞϓϦ֓ཁʢ࣮دΓʣ ref. https:"//developer.android.com/guide/topics/media-apps/media-apps-overview
MediaBrowserService(session/player) class MyMediaService : MediaBrowserServiceCompat() { private lateinit var mediaSession:
MediaSessionCompat private lateinit var player: Player override fun onCreate() { super.onCreate() mediaSession = MediaSessionCompat(this, "MyMediaService").apply { … setCallback(myCallback) ɹɹɹɹɹɹ …
MediaBrowserService(session/player) override fun onCreate() { … } private val myCallback
= object : MediaSessionCompat.Callback() { override fun onPrepare() {} override fun onPlay() {} override fun onPause() {} override fun onStop() {} … }
MediaBrowserService(session/player) … override fun onGetRoot( clientPackageName: String, clientUid: Int, rootHints:
Bundle? ): BrowserRoot? { "// ଓ͞ΕͨΫϥΠΞϯτͷݕূΛ͢Δ "// ଓΛڋ൱͢Δͱ͖nullΛฦ͢ return BrowserRoot("root", null) }
MediaBrowserService(session/player) … override fun onLoadChildren( parentId: String, result: Result<MutableList<MediaBrowserCompat.MediaItem">> )
{ "// ΫϥΠΞϯτʹϝσΟΞͷϦετΛฦ͢ val list = getMetadata() result.sendResult(list) } …
Activity(UI/controller) class MediaPlayerActivity : AppCompatActivity() { private lateinit var mediaBrowser:
MediaBrowserCompat private lateinit var mediaController: MediaControllerCompat override fun onCreate(savedInstanceState: Bundle?) { … mediaBrowser = MediaBrowserCompat( this, ComponentName(this, MyMediaService"::class.java), connectionCallbacks, null
Activity(UI/controller) class MediaPlayerActivity : AppCompatActivity() { private lateinit var mediaBrowser:
MediaBrowserCompat private lateinit var mediaController: MediaControllerCompat override fun onCreate(savedInstanceState: Bundle?) { … } override fun onStart() { super.onStart() "// MediaBrowserServiceʹଓ mediaBrowser.connect()
Activity(UI/controller) class MediaPlayerActivity : AppCompatActivity() { … private lateinit var
mediaController: MediaControllerCompat … private val connectionCallbacks = object : MediaBrowserCompat.ConnectionCallback() { override fun onConnected() { "// sessionͷτʔΫϯ͔ΒcontrollerΛੜ mediaController = MediaControllerCompat(this@MediaPlayerActivity, mediaBrowser.sessionToken) .apply { registerCallback(controllerCallback) } "// UIͷૢ࡞ʹԠͯ͡controllerΛհͯ͠ΦʔσΟΦΛૢ࡞ "// ྫ) ࠶ੜɿmediaController.transportControls.play()
Activity(UI/controller) class MediaPlayerActivity : AppCompatActivity() { … private var controllerCallback
= object : MediaControllerCompat.Callback() { override fun onMetadataChanged(metadata: MediaMetadataCompat?) { "// ࠶ੜதͷίϯςϯπใͷมԽʹԠͯ͡UIΛߋ৽ } override fun onPlaybackStateChanged(state: PlaybackStateCompat?) { "// ࠶ੜͷঢ়ଶ(࠶ੜதఀࢭ)ͷมԽʹԠͯ͡UIΛߋ৽͢Δ } }
શʹཧղͨ͠ʁ
·ͱΊ •ԻΛ࠶ੜ͢Δ͚ͩͳΒ؆୯ʂ& •ΦʔσΟΦΞϓϦͰߟྀ͢Δ͜ͱҙ֎ͱଟ͍ • ࠓ͍ͯ͠ͳ͍͜ͱͨ͘͞Μ͋Δ…ʂ •ڵຯ͕༙͍ͨΒ࡞ͬͯΈΑ͏ʂ' • खΛಈ͔͢ͷେࣄʂ%