@javascriptcommon/react-native-track-player 4.1.5 → 4.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +13 -7
- package/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt +5 -0
- package/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt +5 -1
- package/android/src/main/java/com/lovegaoshi/kotlinaudio/player/QueuedAudioPlayer.kt +1 -2
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -10,7 +10,7 @@ buildscript {
|
|
|
10
10
|
mavenCentral()
|
|
11
11
|
}
|
|
12
12
|
dependencies {
|
|
13
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
13
|
+
classpath 'com.android.tools.build:gradle:8.12.2'
|
|
14
14
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -55,6 +55,12 @@ android {
|
|
|
55
55
|
jvmTarget = "1.8"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
sourceSets {
|
|
60
|
+
main {
|
|
61
|
+
java.srcDirs += ["build/generated/source/codegen"]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
repositories {
|
|
@@ -77,15 +83,15 @@ dependencies {
|
|
|
77
83
|
implementation "com.facebook.react:react-native:+"
|
|
78
84
|
}
|
|
79
85
|
// Make sure we're using androidx
|
|
80
|
-
implementation "androidx.core:core-ktx:1.
|
|
86
|
+
implementation "androidx.core:core-ktx:1.17.0"
|
|
81
87
|
implementation "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
|
|
82
|
-
implementation "androidx.lifecycle:lifecycle-process:2.9.
|
|
83
|
-
implementation 'androidx.media:media:1.7.
|
|
88
|
+
implementation "androidx.lifecycle:lifecycle-process:2.9.3"
|
|
89
|
+
implementation 'androidx.media:media:1.7.1'
|
|
84
90
|
|
|
85
|
-
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.
|
|
91
|
+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.3")
|
|
86
92
|
implementation("androidx.activity:activity-compose:1.10.1")
|
|
87
|
-
implementation("androidx.compose.ui:ui:1.
|
|
88
|
-
implementation("androidx.compose.ui:ui-graphics:1.
|
|
93
|
+
implementation("androidx.compose.ui:ui:1.9.0")
|
|
94
|
+
implementation("androidx.compose.ui:ui-graphics:1.9.0")
|
|
89
95
|
|
|
90
96
|
implementation("androidx.media3:media3-exoplayer:1.8.0")
|
|
91
97
|
implementation("androidx.media3:media3-session:1.8.0")
|
|
@@ -29,6 +29,7 @@ import timber.log.Timber
|
|
|
29
29
|
import java.util.*
|
|
30
30
|
import androidx.core.net.toUri
|
|
31
31
|
import com.facebook.react.module.annotations.ReactModule
|
|
32
|
+
import com.lovegaoshi.kotlinaudio.models.AudioPlayerState
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -768,6 +769,10 @@ class MusicModule(reactContext: ReactApplicationContext) : NativeTrackPlayerSpec
|
|
|
768
769
|
callback.resolve(musicService.lastConnectedPackage)
|
|
769
770
|
}
|
|
770
771
|
|
|
772
|
+
fun isPlaying(): Boolean {
|
|
773
|
+
return musicService.state == AudioPlayerState.PLAYING
|
|
774
|
+
}
|
|
775
|
+
|
|
771
776
|
// Bridgeless interop layer tries to pass the `Job` from `scope.launch` to the JS side
|
|
772
777
|
// which causes an exception. We can work around this using a wrapper.
|
|
773
778
|
private fun launchInScope(block: suspend () -> Unit) {
|
|
@@ -1001,10 +1001,14 @@ class MusicService : HeadlessJsMediaService() {
|
|
|
1001
1001
|
override fun onDestroy() {
|
|
1002
1002
|
Timber.tag("APM").d("RNTP service is destroyed.")
|
|
1003
1003
|
if (::player.isInitialized) {
|
|
1004
|
-
|
|
1004
|
+
// moved down ->
|
|
1005
|
+
// mediaSession.release()
|
|
1005
1006
|
player.destroy()
|
|
1006
1007
|
}
|
|
1007
1008
|
|
|
1009
|
+
// -> Attempt to fix https://github.com/doublesymmetry/react-native-track-player/issues/2485
|
|
1010
|
+
mediaSession.release()
|
|
1011
|
+
|
|
1008
1012
|
instance = null
|
|
1009
1013
|
progressUpdateJob?.cancel()
|
|
1010
1014
|
super.onDestroy()
|
|
@@ -100,8 +100,7 @@ class QueuedAudioPlayer(
|
|
|
100
100
|
add(item)
|
|
101
101
|
} else {
|
|
102
102
|
players().forEach { p ->
|
|
103
|
-
p.
|
|
104
|
-
p.removeMediaItem(currentIndex)
|
|
103
|
+
p.replaceMediaItem(currentIndex, parseAudioItem(item))
|
|
105
104
|
p.seekTo(currentIndex, C.TIME_UNSET)
|
|
106
105
|
}
|
|
107
106
|
exoPlayer.prepare()
|