Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Proposal) [#264] media3 integration #266

Merged
merged 46 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4d024e6
init :core:playback module
workspace Aug 30, 2023
69cb906
sessions.json에 video sample 추가
workspace Aug 30, 2023
3c0e6ef
Video model 추가 및 Mapper 수정
workspace Aug 30, 2023
7495ff4
GithubRawApi의 endPoint를 workspace 소유 repository의 media3 branch로 변경
workspace Aug 30, 2023
ef74596
Session model 내 video type을 non-null로 수정
workspace Aug 30, 2023
e3ce3fe
media3 dependencies 추가
workspace Aug 30, 2023
b4504e6
sessions.json 업데이트
workspace Aug 31, 2023
145707a
core:playback dependencies 업데이트
workspace Aug 31, 2023
8fde836
Merge branch 'main' of github.com:droidknights/DroidKnights2023_App i…
workspace Aug 31, 2023
c684829
libs.versions.toml update
workspace Aug 31, 2023
dce8d02
재생 중인 Session의 id를 datastore에 기록
workspace Aug 31, 2023
9a5e251
재생 중인 Session id를 저장/조회할 수 있도록 SessionRepository 수정 및 Usecase 구현
workspace Aug 31, 2023
64f7472
core:playback 구현
workspace Aug 31, 2023
9190130
feature:player 구현
workspace Aug 31, 2023
a31c1c0
feature:session에서 player로의 route 구현
workspace Aug 31, 2023
a399cf8
feature:main에서 player NavGraph 연결
workspace Aug 31, 2023
baa6902
플레이어 가로 화면에서 시스템 UI가 사라지는 동작 구현
workspace Aug 31, 2023
172945e
app module에서 SessionActivityIntentProvider 및 di 구현
workspace Aug 31, 2023
01ef8b9
fix: FOREGROUND_SERVICE 권한 추가
workspace Aug 31, 2023
8897b93
Android Auto 지원
workspace Aug 31, 2023
4fda44b
onPlaybackResumption 대응 추가
workspace Sep 1, 2023
a6239cf
Android Automotive 지원 추가
workspace Sep 1, 2023
b6c95ec
package rename tv -> automotive
workspace Sep 1, 2023
11f16f3
누락된 feature:player dependency 추가
workspace Sep 1, 2023
1ac9923
compile sdk 34로 상향
workspace Sep 1, 2023
3be75f9
tv app 구현
workspace Sep 1, 2023
6cd0f3a
라이브러리 최신화
workspace Sep 1, 2023
c55d900
wear os app 구현
workspace Sep 2, 2023
93c5e6a
lint fix
workspace Sep 2, 2023
ab565ef
Merge remote-tracking branch 'origin/main' into media3
workspace Sep 14, 2023
7d9204d
GithubRawApi url 변경
workspace Sep 14, 2023
8f3638c
Merge remote-tracking branch 'origin/reference-media3' into media3
workspace Sep 14, 2023
ef0a703
Application -> @ApplicationContext로 대체
workspace Oct 10, 2023
99b5a04
wear, tv SessionCardPreview를 위한 data에 isBookmarked 추가
workspace Oct 10, 2023
35a16d2
PlaybackStateListener에서 player를 attach할 때 중복되는 기존 job을 취소 처리
workspace Oct 10, 2023
9955684
GetBookmarkedSessionsUseCaseTest 수정
workspace Oct 10, 2023
8f4377c
재생 중인 Session을 저장하는 로직 관련 수정
workspace Oct 10, 2023
eb2781b
fix: DefaultSessionRepositoryTest
workspace Oct 11, 2023
d905dc4
불필요한 underscore 제거
workspace Oct 11, 2023
e788ab6
try catch 구문을 runCatching으로 대체
workspace Oct 11, 2023
649e73c
Session의 video를 non-null -> nullable type으로 변경
workspace Oct 11, 2023
29674ec
POST_NOTIFICATIONS permission 추가
workspace Oct 11, 2023
aec471e
fix lint
workspace Oct 11, 2023
2263e4c
README 업데이트
workspace Oct 11, 2023
bb6dc76
request endpoint를 folk repository url로 변경
workspace Oct 11, 2023
e4ad4f1
Merge pull request #4 from workspace/media3-main
workspace Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.Application
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.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
internal object AndroidModule {
@Provides
fun provideContext(app: Application): Context = app
workspace marked this conversation as resolved.
Show resolved Hide resolved

@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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: SessionActivityIntentProvider interface의 구현체를 주입하기 위함인데 본 레퍼런스에선 이런 분리를 세세하게 고민하지 않았던 편.

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,22 @@
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.components.SingletonComponent

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

@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
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문) 이 class의 목적이 어떻게 될까요?
PendingIntent를 생성하는거라면 exteions 형태로 만들어도 충분할것 같아보입니다.
객체 형태로 만들어져 있어야할 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/droidknights/DroidKnights2023_App/pull/266/files/7d9204d899004c7b001fd1a4adb74721980fa591#diff-281b1044609ea759a0253956cdbac7889c69d2c1b66a445f36702e59f495c2a4R74-R81

core:playback module에서 MediaLibrarySession.Builder에서 MediaSession 클릭 시 사용자를 이동시키기 위한 setSessionActivity method에 쓰입니다. 각 앱마다 동작이 다르기에 interface를 선언하고 각 앱마다 다른 구현체를 넣어줬습니다.

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>
1 change: 1 addition & 0 deletions app-wear-os/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions app-wear-os/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
id("droidknights.android.application")
}

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

defaultConfig {
applicationId = "com.droidknights.app2023.wear"
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.navigation)
implementation(projects.core.playback)
implementation(projects.feature.wearMain)
implementation(projects.feature.wearPlayer)
}
21 changes: 21 additions & 0 deletions app-wear-os/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
Loading