diff --git a/app/build.gradle b/app/build.gradle index 68d70a3..9cb98ed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,14 +63,14 @@ dependencies { def nav_compose_version = '2.4.1' implementation "androidx.navigation:navigation-compose:$nav_compose_version" - def lifecycle_version = '2.4.0' + def lifecycle_version = '2.4.1' implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" implementation 'androidx.activity:activity-compose:1.4.0' implementation "androidx.datastore:datastore-preferences:1.0.0" - def room_version = '2.4.1' + def room_version = '2.4.2' kapt "androidx.room:room-compiler:$room_version" implementation "androidx.room:room-ktx:$room_version" implementation "androidx.room:room-runtime:$room_version" @@ -78,7 +78,7 @@ dependencies { implementation "com.squareup.okhttp3:okhttp:4.9.0" - def media3_version = '1.0.0-alpha01' + def media3_version = '1.0.0-alpha02' implementation "androidx.media3:media3-ui:$media3_version" implementation "androidx.media3:media3-exoplayer:$media3_version" implementation "androidx.media3:media3-session:$media3_version" diff --git a/app/src/main/java/net/blumia/pcmdroid/MainActivity.kt b/app/src/main/java/net/blumia/pcmdroid/MainActivity.kt index 6ab4e8b..c0e852c 100644 --- a/app/src/main/java/net/blumia/pcmdroid/MainActivity.kt +++ b/app/src/main/java/net/blumia/pcmdroid/MainActivity.kt @@ -1,5 +1,6 @@ package net.blumia.pcmdroid +import android.annotation.SuppressLint import android.content.ComponentName import android.os.Bundle import androidx.activity.ComponentActivity @@ -74,6 +75,7 @@ class MainActivity : ComponentActivity() { MediaBrowser.releaseFuture(browserFuture) } + @androidx.annotation.OptIn(UnstableApi::class) private fun pushRoot() { // browser can be initialized many times // only push root at the first initialization diff --git a/app/src/main/java/net/blumia/pcmdroid/service/PlaybackService.kt b/app/src/main/java/net/blumia/pcmdroid/service/PlaybackService.kt index 6face65..68a6357 100644 --- a/app/src/main/java/net/blumia/pcmdroid/service/PlaybackService.kt +++ b/app/src/main/java/net/blumia/pcmdroid/service/PlaybackService.kt @@ -4,11 +4,19 @@ import android.app.PendingIntent.FLAG_IMMUTABLE import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.content.Intent import android.os.Build +import android.util.Log import androidx.core.app.TaskStackBuilder import androidx.media3.common.AudioAttributes +import androidx.media3.common.MediaItem +import androidx.media3.common.MediaMetadata +import androidx.media3.common.MediaMetadata.FOLDER_TYPE_MIXED +import androidx.media3.common.util.UnstableApi import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.session.LibraryResult import androidx.media3.session.MediaLibraryService import androidx.media3.session.MediaSession +import com.google.common.util.concurrent.Futures +import com.google.common.util.concurrent.ListenableFuture import net.blumia.pcmdroid.MainActivity class PlaybackService : MediaLibraryService() { @@ -20,6 +28,35 @@ class PlaybackService : MediaLibraryService() { private inner class CustomMediaLibrarySessionCallback : MediaLibrarySession.MediaLibrarySessionCallback { + @androidx.annotation.OptIn(UnstableApi::class) + override fun onGetLibraryRoot( + session: MediaLibrarySession, + browser: MediaSession.ControllerInfo, + params: LibraryParams? + ): ListenableFuture> { + Log.d("aaa", "onGetLibraryRoot ${params.toString()}") + val metadata = MediaMetadata.Builder() + .setTitle("Root") + .setIsPlayable(false) + .setFolderType(FOLDER_TYPE_MIXED) + .build() + val item = MediaItem.Builder() + .setMediaId("test") + .setMediaMetadata(metadata) + .build() + return Futures.immediateFuture(LibraryResult.ofItem(item, params)) + //MediaMetadata +// return super.onGetLibraryRoot(session, browser, params) + } + + override fun onGetItem( + session: MediaLibrarySession, + browser: MediaSession.ControllerInfo, + mediaId: String + ): ListenableFuture> { + Log.d("aaa", "onGetItem $mediaId") + return super.onGetItem(session, browser, mediaId) + } } override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession { @@ -37,6 +74,7 @@ class PlaybackService : MediaLibraryService() { super.onDestroy() } + @androidx.annotation.OptIn(UnstableApi::class) private fun initializeSessionAndPlayer() { player = ExoPlayer.Builder(this) diff --git a/app/src/main/java/net/blumia/pcmdroid/ui/NavGraph.kt b/app/src/main/java/net/blumia/pcmdroid/ui/NavGraph.kt index da5b17c..a080fea 100644 --- a/app/src/main/java/net/blumia/pcmdroid/ui/NavGraph.kt +++ b/app/src/main/java/net/blumia/pcmdroid/ui/NavGraph.kt @@ -7,6 +7,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState import androidx.lifecycle.MutableLiveData import androidx.media3.common.MediaItem +import androidx.media3.common.util.UnstableApi import androidx.media3.session.MediaBrowser import androidx.navigation.NavHostController import androidx.navigation.NavType @@ -33,6 +34,7 @@ object MainDestinations { const val SETTINGS_ROUTE = "settings" } +@androidx.annotation.OptIn(UnstableApi::class) @Composable fun NavGraph( mainViewModel: MainViewModel, @@ -73,6 +75,7 @@ fun NavGraph( onSongItemClicked = { song, songs -> Log.d("vvv", song.url + browser.toString()) val playlist = browser ?: return@MainPlayer + Log.d("vvv", song.url + browser.toString()) val item = MediaItem.Builder().setUri(song.url).build() diff --git a/build.gradle b/build.gradle index 8b18604..2cafdd0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { - compose_version = '1.1.0' + compose_version = '1.1.1' } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '7.1.1' apply false - id 'com.android.library' version '7.1.1' apply false + id 'com.android.application' version '7.1.2' apply false + id 'com.android.library' version '7.1.2' apply false id 'org.jetbrains.kotlin.android' version '1.6.10' apply false }