Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ android {
minSdk = 26
targetSdk = 37
// For X.Y.Z use X*1000000 + Y*10000 + Z*100. Update both values for each release.
versionCode = 2290000
versionName = "2.29.0"
versionCode = 2290100
versionName = "2.29.1"

testInstrumentationRunner = providers.gradleProperty("crosstuneTestRunner").orElse("androidx.test.runner.AndroidJUnitRunner").get()

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/astrovm/crosstune/Playback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,9 @@ internal class MediaSessionPlayback(
val recording = RecordingKey.playing(packageName, playing.getString(MediaMetadata.METADATA_KEY_MEDIA_ID), length)
if (song.recordingId?.startsWith("$packageName:") == true && recording != null && song.recordingId != recording) return true
// Far from as long as the song, it's another version of it, e.g. the album's take of a single; a video may open with more.
return !isVideo() && length != null && song.lengthMs?.let { abs(it - length) > SAME_RECORDING_LENGTH_MS } == true
// As far off as a song found for a link may be, or the one Crosstune had the app play wouldn't be followed there:
// a remaster on Deezer is 3:28, and the same song on YouTube Music 3:32.
return !isVideo() && length != null && song.lengthMs?.let { abs(it - length) > ExactMatcher.SAME_LENGTH_MS } == true
}

private fun MediaController.plays(song: MusicMetadata): Boolean {
Expand Down
17 changes: 16 additions & 1 deletion app/src/test/java/com/astrovm/crosstune/PlaybackTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,18 @@ class PlaybackTest {
assertEquals(221_501L, playback.recording(played)?.lengthMs)
}

@Test
fun aSongFoundForALinkIsFollowedThoughItsAppHasItSomeSecondsLonger() {
allow()
// Deezer's remaster is 3:28. YouTube Music, sent to the song found for it, plays it as 3:32.9, by another name.
val there = player("com.google.android.apps.youtube.music", "YouTube Music", "愛が止まらない ~TURN IT INTO LOVE~", "Wink",
album = "愛が止まらない ~TURN IT INTO LOVE~", state = PlaybackState.STATE_PLAYING, duration = 212_903)
shadowOf(sessions).addController(there)
val linked = MusicMetadata("愛が止まらない ~Turn it into love~ (Original Remastered 2018)", "WINK", lengthMs = 208_000)
assertEquals(212_903L, playback.recording(linked)?.lengthMs)
assertEquals(true, followed(linked).last()?.clock?.playing)
}

@Test
fun anotherVersionOfASongPausedInItsAppIsntTheOneAskedFor() {
allow()
Expand All @@ -2573,7 +2585,10 @@ class PlaybackTest {
assertNull(followed(single).last())
// The album take is, said a second longer elsewhere too, or as far off as one take's length is said to be, and so is a song of no known length.
assertEquals(262_000L, playback.recording(single.copy(lengthMs = 263_000))?.lengthMs)
assertEquals(262_000L, playback.recording(single.copy(lengthMs = 262_000 + SAME_RECORDING_LENGTH_MS))?.lengthMs)
assertEquals(262_000L, playback.recording(single.copy(lengthMs = 262_000 + ExactMatcher.SAME_LENGTH_MS))?.lengthMs)
assertEquals(262_000L, playback.recording(single.copy(lengthMs = 262_000 - ExactMatcher.SAME_LENGTH_MS))?.lengthMs)
assertNull(playback.recording(single.copy(lengthMs = 262_000 + ExactMatcher.SAME_LENGTH_MS + 1)))
assertNull(playback.recording(single.copy(lengthMs = 262_000 - ExactMatcher.SAME_LENGTH_MS - 1)))
assertEquals(262_000L, playback.recording(single.copy(lengthMs = null))?.lengthMs)
// A video may open with more than its song, so its length tells nothing.
val video = player("com.google.android.apps.youtube.music", "YouTube Music", "Bizarre Love Triangle", "New Order", state = PlaybackState.STATE_PAUSED, duration = 262_000)
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/2290100.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lyrics and practice cards follow a song that its app has a few seconds longer than its link.
Loading