@javascriptcommon/react-native-track-player 4.1.32 → 4.1.33
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.
|
@@ -984,6 +984,12 @@ class MusicService : HeadlessJsMediaService() {
|
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
986
|
|
|
987
|
+
is MediaSessionCallback.PLAY_FROM_ID -> {
|
|
988
|
+
Bundle().apply {
|
|
989
|
+
putString("id", it.mediaId)
|
|
990
|
+
emit(MusicEvents.BUTTON_PLAY_FROM_ID, this)
|
|
991
|
+
}
|
|
992
|
+
}
|
|
987
993
|
is MediaSessionCallback.CUSTOMACTION -> {
|
|
988
994
|
when (it.customAction) {
|
|
989
995
|
"shuffle" -> emit(MusicEvents.BUTTON_SHUFFLE)
|
|
@@ -13,5 +13,6 @@ sealed class MediaSessionCallback {
|
|
|
13
13
|
object REWIND : MediaSessionCallback()
|
|
14
14
|
object STOP : MediaSessionCallback()
|
|
15
15
|
class SEEK(val positionMs: Long): MediaSessionCallback()
|
|
16
|
+
class PLAY_FROM_ID(val mediaId: String): MediaSessionCallback()
|
|
16
17
|
class CUSTOMACTION(val customAction: String): MediaSessionCallback()
|
|
17
18
|
}
|
|
@@ -893,6 +893,24 @@ abstract class AudioPlayer internal constructor(
|
|
|
893
893
|
playerEventHolder.updateOnPlayerActionTriggeredExternally(MediaSessionCallback.STOP)
|
|
894
894
|
}
|
|
895
895
|
|
|
896
|
+
override fun seekToDefaultPosition(mediaItemIndex: Int) {
|
|
897
|
+
// Called when Android Auto user taps a queue item (COMMAND_SEEK_TO_MEDIA_ITEM).
|
|
898
|
+
// Intercept to prevent ExoPlayer from trying to load tracks with empty URLs
|
|
899
|
+
// (notPlayable). Emit PLAY_FROM_ID so the JS side resolves the source first.
|
|
900
|
+
try {
|
|
901
|
+
val mediaItem = this@AudioPlayer.exoPlayer.getMediaItemAt(mediaItemIndex)
|
|
902
|
+
val mediaId = mediaItem?.mediaId
|
|
903
|
+
if (!mediaId.isNullOrEmpty()) {
|
|
904
|
+
playerEventHolder.updateOnPlayerActionTriggeredExternally(
|
|
905
|
+
MediaSessionCallback.PLAY_FROM_ID(mediaId)
|
|
906
|
+
)
|
|
907
|
+
return
|
|
908
|
+
}
|
|
909
|
+
} catch (_: Exception) { }
|
|
910
|
+
// Fallback: delegate to ExoPlayer
|
|
911
|
+
super.seekToDefaultPosition(mediaItemIndex)
|
|
912
|
+
}
|
|
913
|
+
|
|
896
914
|
override fun seekTo(mediaItemIndex: Int, positionMs: Long) {
|
|
897
915
|
playerEventHolder.updateOnPlayerActionTriggeredExternally(
|
|
898
916
|
MediaSessionCallback.SEEK(
|
package/package.json
CHANGED