diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 6501d8c..042657f 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -109,7 +109,7 @@ dependencies {
//---------------User Interface---------------//
//Core UI libraries
- api(platform(libs.compose.bom))
+ api(platform(libs.compose.bom.canary))
//Accompanist libraries
implementation(libs.bundles.accompanist)
diff --git a/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaServiceHandler.kt b/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaServiceHandler.kt
index e30398c..2d4aee1 100644
--- a/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaServiceHandler.kt
+++ b/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaServiceHandler.kt
@@ -3,7 +3,11 @@ package com.bobbyesp.mediaplayer.service
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player
+import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ExoPlayer
+import androidx.media3.exoplayer.analytics.AnalyticsListener
+import androidx.media3.exoplayer.analytics.PlaybackStats
+import androidx.media3.exoplayer.analytics.PlaybackStatsListener
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
@@ -16,9 +20,10 @@ import javax.inject.Inject
* It provides methods to control the media player such as play, pause, stop, and seek.
* It also provides methods to manage the media queue such as set, add, and remove media items.
*/
+@UnstableApi
class MediaServiceHandler @Inject constructor(
private val player: ExoPlayer
-) : Player.Listener {
+) : Player.Listener, PlaybackStatsListener.Callback {
private val _mediaState = MutableStateFlow(MediaState.Idle)
val mediaState = _mediaState.asStateFlow()
@@ -208,6 +213,13 @@ class MediaServiceHandler @Inject constructor(
MediaState.Playing(false)
}
}
+
+ override fun onPlaybackStatsReady(
+ eventTime: AnalyticsListener.EventTime,
+ playbackStats: PlaybackStats
+ ) {
+ TODO("Not yet implemented")
+ }
}
sealed class PlayerEvent {
diff --git a/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaplayerService.kt b/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaplayerService.kt
index ba65d2c..e990806 100644
--- a/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaplayerService.kt
+++ b/app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/service/MediaplayerService.kt
@@ -10,9 +10,9 @@ import com.bobbyesp.mediaplayer.service.notifications.MediaNotificationManager
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
+@UnstableApi
@AndroidEntryPoint
class MediaplayerService : MediaSessionService() {
-
@Inject
lateinit var mediaSession: MediaSession
@@ -50,10 +50,14 @@ class MediaplayerService : MediaSessionService() {
super.onDestroy()
}
- override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaSession {
- return mediaSession
+ override fun onTaskRemoved(rootIntent: Intent?) {
+ super.onTaskRemoved(rootIntent)
+ stopSelf()
}
+ override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaSession =
+ mediaSession
+
inner class MusicBinder : Binder() {
val service: MediaplayerService
get() = this@MediaplayerService
diff --git a/app/src/main/java/com/bobbyesp/metadator/MainActivity.kt b/app/src/main/java/com/bobbyesp/metadator/MainActivity.kt
index 815ad9e..2e0b859 100644
--- a/app/src/main/java/com/bobbyesp/metadator/MainActivity.kt
+++ b/app/src/main/java/com/bobbyesp/metadator/MainActivity.kt
@@ -14,6 +14,7 @@ import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
+import androidx.media3.common.util.UnstableApi
import com.bobbyesp.mediaplayer.service.ConnectionHandler
import com.bobbyesp.mediaplayer.service.MediaplayerService
import com.bobbyesp.metadator.presentation.Navigator
@@ -24,6 +25,7 @@ import dagger.hilt.android.AndroidEntryPoint
import setupFirebase
import javax.inject.Inject
+@androidx.annotation.OptIn(UnstableApi::class)
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private var isMusicPlayerServiceStarted = false
@@ -44,7 +46,6 @@ class MainActivity : ComponentActivity() {
}
activity = this
setupFirebase()
- startMediaPlayerService()
setContent {
val windowSizeClass = calculateWindowSizeClass(this)
AppLocalSettingsProvider(windowSizeClass.widthSizeClass, connectionHandler) {
@@ -58,9 +59,13 @@ class MainActivity : ComponentActivity() {
}
}
- override fun onDestroy() {
- super.onDestroy()
- stopService(Intent(this, MediaplayerService::class.java))
+ override fun onStart() {
+ super.onStart()
+ startMediaPlayerService()
+ }
+
+ override fun onStop() {
+ super.onStop()
unbindService(serviceConnection)
isMusicPlayerServiceStarted = false
}
@@ -96,8 +101,6 @@ class MainActivity : ComponentActivity() {
companion object {
private lateinit var activity: MainActivity
- fun getActivity(): MainActivity {
- return activity
- }
+ fun getActivity(): MainActivity = activity
}
}
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 00e2880..aafaff5 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,28 +1,28 @@
[versions]
#General, lifecycle and core
-agp = "8.5.0-alpha02"
+agp = "8.5.0-alpha06"
firebaseCrashlyticsGradle = "2.9.9"
-gradle = "8.5.0-alpha02"
+gradle = "8.5.0-alpha06"
kotlin = "1.9.23"
appcompat = "1.7.0-alpha03"
-core-ktx = "1.12.0"
+core-ktx = "1.13.0"
legacySupportV4 = "1.0.0"
lifecycle-runtime-ktx = "2.7.0"
-activity-compose = "1.8.2"
+activity-compose = "1.9.0"
compose-compiler = "1.5.11"
ksp = "1.9.23-1.0.19"
lyricfier = "1.0"
splashscreen = "1.0.1"
material = "1.11.0"
-media3 = "1.3.0"
+media3 = "1.3.1"
leakcanary = "2.13"
#Compose
-compose-bom = "2024.04.00"
-compose-bom-canary = "2024.04.00-alpha01"
+compose-bom = "2024.04.01"
+compose-bom-canary = "2024.04.00-alpha02"
constraintLayout = "1.1.0-alpha13"
androidx-compose-material3 = "1.2.1"
-compose-util = "1.6.5"
+compose-util = "1.6.6"
accompanist = "0.34.0"
compose-pagination = "3.2.1"
commonsIo = "2.15.0"
@@ -62,7 +62,7 @@ hilt-ext = "1.2.0"
#Database
room = "2.6.1"
-datastore = "1.0.0"
+datastore = "1.1.0"
#High performance Key-value storage
mmkv = "1.3.2"
@@ -75,9 +75,9 @@ markdown = "0.3.7"
#Firebase, GMS...
firebaseAuth = "22.3.1"
-gmsPlayServicesAuth = "21.0.0"
+gmsPlayServicesAuth = "21.1.0"
googleServices = "4.4.1"
-firebaseBom = "32.8.0"
+firebaseBom = "32.8.1"
#Others
taglib = "1.0.0-alpha07"
@@ -116,7 +116,7 @@ compose-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" }
-compose-animation-graphics = { group = "androidx.compose.animation", name = "animation-graphics" }
+compose-animation = { group = "androidx.compose.animation", name = "animation" }
compose-ui = { group = "androidx.compose.ui", name = "ui" }
compose-material = { group = "androidx.compose.material", name = "material" }
compose-ui-util = { group = "androidx.compose.ui", name = "ui-util", version.ref = "compose-util" }
@@ -263,7 +263,7 @@ androidx-baselineprofile = { id = "androidx.baselineprofile", version.ref = "and
core = ["core-ktx", "lifecycle-runtime-ktx", "lifecycle-compose-runtime", "lifecycle-compose-viewModel", "activity-compose", "core-appcompat", "core-splashscreen"]
ktor = ["ktor-android", "ktor-okhttp" ,"ktor-core", "ktor-serialization", "ktor-logging", "ktor-contentnegotiation", "ktor-encoding"]
accompanist = ["accompanist-navigation-animation", "accompanist-permissions", "accompanist-webview", "accompanist-pager-layouts", "accompanist-pager-indicators", "accompanist-flowlayout", "accompanist-material"]
-compose = ["compose-ui-util","compose-graphics", "compose-runtime", "compose-foundation", "compose-material-iconsExtended", "compose-animation-graphics", "compose-ui", "compose-material", "compose-material3", "compose-navigation" ,"compose-material3-windowSizeClass", "compose-constraintLayout"]
+compose = ["compose-ui-util", "compose-graphics", "compose-runtime", "compose-foundation", "compose-material-iconsExtended", "compose-animation", "compose-ui", "compose-material", "compose-material3", "compose-navigation", "compose-material3-windowSizeClass", "compose-constraintLayout"]
hilt = ["compose-hilt-navigation", "hilt-android"]
hilt-kapt = ["hilt-compiler", "hilt-ext-compiler"]
pagination = ["paging-compose", "paging-runtime"]