Skip to content

Commit 893e2bc

Browse files
authored
[Jetcaster]: Auto play episode on next. (#1346)
2 parents 5e81ca2 + 3771d3e commit 893e2bc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ class MockEpisodePlayer(
127127
}
128128

129129
next()
130-
play()
131130
}
132131

133132
override fun pause() {
@@ -168,6 +167,7 @@ class MockEpisodePlayer(
168167
val nextEpisode = q[0]
169168
currentEpisode = nextEpisode
170169
queue.value = q - nextEpisode
170+
play()
171171
}
172172

173173
override fun previous() {

Jetcaster/core/src/test/kotlin/com/example/jetcaster/core/player/MockEpisodePlayerTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import kotlinx.coroutines.test.advanceTimeBy
2424
import kotlinx.coroutines.test.advanceUntilIdle
2525
import kotlinx.coroutines.test.runTest
2626
import org.junit.Assert.assertEquals
27+
import org.junit.Assert.assertTrue
2728
import org.junit.Test
2829

2930
@OptIn(ExperimentalCoroutinesApi::class)
@@ -62,6 +63,22 @@ class MockEpisodePlayerTest {
6263
assertEquals(testEpisodes.first(), mockEpisodePlayer.currentEpisode)
6364
}
6465

66+
@Test
67+
fun whenNext_queueIsNotEmpty_autoPlaysNextEpisode() = runTest(testDispatcher) {
68+
val duration = Duration.ofSeconds(60)
69+
val currEpisode = PlayerEpisode(
70+
uri = "currentEpisode",
71+
duration = duration
72+
)
73+
mockEpisodePlayer.currentEpisode = currEpisode
74+
testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }
75+
76+
mockEpisodePlayer.next()
77+
advanceTimeBy(100)
78+
79+
assertTrue(mockEpisodePlayer.playerState.value.isPlaying)
80+
}
81+
6582
@Test
6683
fun whenNext_queueIsEmpty_doesNothing() {
6784
val episode = testEpisodes[0]

0 commit comments

Comments
 (0)