diff --git a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/extension/Player.kt b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/extension/Player.kt index 2699fc3e5..12dab3d92 100644 --- a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/extension/Player.kt +++ b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/extension/Player.kt @@ -7,26 +7,6 @@ package ch.srgssr.pillarbox.player.extension import androidx.media3.common.MediaItem import androidx.media3.common.Player -/** - * Resume playback - */ -fun Player.startPlayback() { - when (playbackState) { - Player.STATE_IDLE -> { - prepare() - } - - Player.STATE_ENDED -> { - seekToDefaultPosition() - } - - else -> { - // Nothing - } - } - play() -} - /** * Get a snapshot of the current media items */ diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/extension/PlayerTest.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/extension/PlayerTest.kt index 0c9e5f5b6..5ed3eddea 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/extension/PlayerTest.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/extension/PlayerTest.kt @@ -8,73 +8,11 @@ import androidx.media3.common.MediaItem import androidx.media3.common.PlaybackParameters import androidx.media3.common.Player import io.mockk.every -import io.mockk.justRun import io.mockk.mockk -import io.mockk.verifySequence import kotlin.test.Test import kotlin.test.assertEquals class PlayerTest { - @Test - fun `startPlayback with player buffering`() { - val player = mockk { - every { playbackState } returns Player.STATE_BUFFERING - justRun { play() } - } - player.startPlayback() - - verifySequence { - player.playbackState - player.play() - } - } - - @Test - fun `startPlayback with player ended`() { - val player = mockk { - every { playbackState } returns Player.STATE_ENDED - justRun { seekToDefaultPosition() } - justRun { play() } - } - player.startPlayback() - - verifySequence { - player.playbackState - player.seekToDefaultPosition() - player.play() - } - } - - @Test - fun `startPlayback with player idle`() { - val player = mockk { - every { playbackState } returns Player.STATE_IDLE - justRun { prepare() } - justRun { play() } - } - player.startPlayback() - - verifySequence { - player.playbackState - player.prepare() - player.play() - } - } - - @Test - fun `startPlayback with player ready`() { - val player = mockk { - every { playbackState } returns Player.STATE_READY - justRun { play() } - } - player.startPlayback() - - verifySequence { - player.playbackState - player.play() - } - } - @Test fun `getCurrentMediaItems without any items`() { val player = mockk {