Skip to content

Commit

Permalink
Merge pull request #266 from workspace/media3
Browse files Browse the repository at this point in the history
(Proposal) [#264] media3 integration
  • Loading branch information
taehwandev authored Apr 5, 2024
2 parents 1a4fe43 + e4ad4f1 commit 05bc31e
Show file tree
Hide file tree
Showing 179 changed files with 3,682 additions and 58 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
<img width="1512" alt="banner" src="https://github.com/workspace/DroidKnights2023-app-with-media3/assets/7759511/1a3c1ef9-7d8d-4782-a307-05255310592b">

# DroidKnights2023 App with media3

2023년 9월 12일 드로이드나이츠에서 발표한 <Jetpack Media3로 좋은 콘텐츠 소비 경험 구현하기>에서 소개한 데모 앱을 공개합니다.

## 발표 자료
https://speakerdeck.com/workspace93/jetpack-media3ro-joheun-kontenceu-sobi-gyeongheom-guhyeonhagi

## Guide

### Emulator 만들기

각 Configuration에 맞는 Emulator를 Android Studio Device Manager에서 생성.

<img width="603" alt="image" src="https://github.com/workspace/DroidKnights2023-app-with-media3/assets/7759511/1fa330c2-807f-482e-85fb-3677662f3138">

### Desktop Head Unit Emulator 만들기 (Android Auto)

공식 [가이드](https://developer.android.com/training/cars/testing/dhu)를 따라 `Desktop Head Unit Emulator(DHU)`를 설치. 모바일 에뮬레이터 또는 실기기가 연결된 상태에서 DHU 실행하면 Android Auto 활성화

<img width="546" alt="image" src="https://github.com/workspace/DroidKnights2023-app-with-media3/assets/7759511/09e4a8bd-8a02-4115-a812-fb25d9c55751">

### Run Configurations

실행 해보고 싶은 것과 Emulator를 고른 뒤 `Run`

<img width="313" alt="image" src="https://github.com/workspace/DroidKnights2023-app-with-media3/assets/7759511/814bfdb4-0fa6-4c95-b9d7-5171433d1894">

- app (통상적인 모바일 앱, Android Auto)
- app-wear-os (워치 앱)
- app-tv (Android TV 앱)
- app-automotive (Android Automotive 앱)

## Resources
### Youtube
- [Google I/O 2014 - Building great multi-media experiences on Android (18:29 ~)](https://www.youtube.com/watch?v=92fgcUNCHic&t=1108s)
- [Android Dev Summit 2021 - What’s next for AndroidX Media and ExoPlayer](https://www.youtube.com/watch?v=sTIBDcyCmCg)
### Android Developers - Media3
- [Introducing Jetpack Media3](https://android-developers.googleblog.com/2021/10/jetpack-media3.html)
- [Media3 is ready to play!](https://android-developers.googleblog.com/2023/03/media3-is-ready-to-play.html)
- [Introduction to Jetpack Media3](https://developer.android.com/guide/topics/media/media3)
### Android Developers - Wear OS, TV, Auto
- [Using Jetpack Compose on Wear OS](https://developer.android.com/training/wearables/compose)
- [Use Jetpack Compose on Android TV](https://developer.android.com/training/tv/playback/compose)
- [Build media apps for cars](https://developer.android.com/training/cars/media)
### Github
- [Media3 Github](https://github.com/androidx/media)

<details>
<summary>DroidKnights2023 App ReadMe 원문</summary>
<img width="1512" alt="banner" src="https://github.com/droidknights/DroidKnights2023_App/assets/32327475/af43b370-3d00-43ab-b389-fa1ad364f5df">

# DroidKnights2023 App
Expand Down Expand Up @@ -101,3 +152,5 @@
- GitHub : [Contributors](https://github.com/droidknights/DroidKnights2023_App/graphs/contributors)
- Designer : Eunbi Ko
- Maintainer : [laco-dev](https://github.com/laco-dev), [wisemuji](https://github.com/wisemuji)

</details>
1 change: 1 addition & 0 deletions app-automotive/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions app-automotive/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id("droidknights.android.application")
}

android {
namespace = "com.droidknights.app2023.automotive"

defaultConfig {
applicationId = "com.droidknights.app2023.automotive"
versionCode = 1
versionName = "1.0"
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("debug")
}
}
}

dependencies {
implementation(projects.core.playback)
implementation(projects.core.designsystem)
}
21 changes: 21 additions & 0 deletions app-automotive/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
26 changes: 26 additions & 0 deletions app-automotive/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<uses-feature
android:name="android.hardware.type.automotive"
android:required="true" />

<application
android:allowBackup="true"
android:appCategory="audio"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DroidKnights2023"
android:name=".DroidKnightsApplication">

<meta-data android:name="com.android.automotive"
android:resource="@xml/automotive_app_desc"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.droidknights.app2023.automotive

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class DroidKnightsApplication : Application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.droidknights.app2023.automotive.di

import android.app.PendingIntent
import android.content.Context
import com.droidknights.app2023.core.playback.session.SessionActivityIntentProvider
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
internal object AndroidModule {
@Provides
fun provideContext(@ApplicationContext context: Context): Context = context

@Provides
fun toPlayerIntentProvider(): SessionActivityIntentProvider =
object : SessionActivityIntentProvider {
override fun toPlayer(): PendingIntent? = null
}
}
5 changes: 5 additions & 0 deletions app-automotive/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions app-automotive/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
4 changes: 4 additions & 0 deletions app-automotive/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#141414</color>
</resources>
3 changes: 3 additions & 0 deletions app-automotive/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">드로이드나이츠 2023 for automotive</string>
</resources>
4 changes: 4 additions & 0 deletions app-automotive/src/main/res/xml/automotive_app_desc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<automotiveApp>
<uses name="media" />
</automotiveApp>
1 change: 1 addition & 0 deletions app-tv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions app-tv/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id("droidknights.android.application")
}

android {
namespace = "com.droidknights.app2023.tv"

defaultConfig {
applicationId = "com.droidknights.app2023.tv"
versionCode = 1
versionName = "1.0"
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("debug")
}
}
}

dependencies {
implementation(projects.core.playback)
implementation(projects.feature.player)
implementation(projects.feature.tvMain)
}
21 changes: 21 additions & 0 deletions app-tv/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
25 changes: 25 additions & 0 deletions app-tv/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="false" />

<application
android:name=".DroidKnightsApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DroidKnights2023"
tools:targetApi="31" />

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.droidknights.app2023.tv

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class DroidKnightsApplication : Application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.droidknights.app2023.tv.di

import android.app.Application
import android.content.Context
import com.droidknights.app2023.core.playback.session.SessionActivityIntentProvider
import com.droidknights.app2023.tv.misc.SessionActivityIntentProviderImpl
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
internal object AndroidModule {
@Provides
fun provideContext(@ApplicationContext context: Context): Context = context

@Provides
fun toPlayerIntentProvider(
impl: SessionActivityIntentProviderImpl
): SessionActivityIntentProvider = impl
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.droidknights.app2023.tv.misc

import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.core.app.TaskStackBuilder
import androidx.core.net.toUri
import com.droidknights.app2023.core.playback.session.SessionActivityIntentProvider
import com.droidknights.app2023.feature.player.navigation.PlayerRoute
import com.droidknights.app2023.feature.tvmain.TvMainActivity
import javax.inject.Inject

class SessionActivityIntentProviderImpl @Inject constructor(
private val context: Context,
) : SessionActivityIntentProvider {
override fun toPlayer(): PendingIntent? {
val deepLinkIntent = Intent(
Intent.ACTION_VIEW,
PlayerRoute.deepLinkUriPattern.toUri(),
context,
TvMainActivity::class.java
)

val deepLinkPendingIntent: PendingIntent? = TaskStackBuilder.create(context).run {
addNextIntentWithParentStack(deepLinkIntent)
getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)

}
return deepLinkPendingIntent
}
}
5 changes: 5 additions & 0 deletions app-tv/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions app-tv/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added app-tv/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app-tv/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app-tv/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions app-tv/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#141414</color>
</resources>
3 changes: 3 additions & 0 deletions app-tv/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">드로이드나이츠 2023 for tv</string>
</resources>
Loading

0 comments on commit 05bc31e

Please sign in to comment.