StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
Avoid stale Stalker temp links while zapping
David Nashash6408bc426ddb
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.ktindex 65b4af13..6cba9cda 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt@@ -1,6 +1,7 @@package com.streamvault.app.ui.screens.playerimport androidx.lifecycle.viewModelScope+import com.streamvault.data.remote.stalker.StalkerUrlFactoryimport com.streamvault.domain.model.Channelimport com.streamvault.domain.model.ChannelNumberingModeimport com.streamvault.domain.model.ContentType@@ -89,6 +90,11 @@ internal fun releaseOutgoingLiveZapPlayback(clearPreload()}+internal fun shouldPreloadAdjacentChannel(+ streamUrl: String,+ isStalkerInternalUrl: (String) -> Boolean+): Boolean = streamUrl.isNotBlank() && !isStalkerInternalUrl(streamUrl)+fun PlayerViewModel.playNext() {clearNumericChannelInput()if (channelList.isEmpty()) return@@ -204,6 +210,8 @@ internal fun PlayerViewModel.changeChannel(index: Int, isAutoFallback: Boolean =stopLiveTimeshift = playerEngine::stopLiveTimeshift,clearPreload = { playerEngine.preload(null) })+ currentResolvedPlaybackUrl = ""+ currentResolvedStreamInfo = nullval channel = channelList[index]currentChannelIndex = indexcurrentContentId = channel.id@@ -256,6 +264,10 @@ internal fun PlayerViewModel.preloadAdjacentChannel(currentIndex: Int) {if (channelList.size < 2) returnval nextIndex = (currentIndex + 1) % channelList.sizeval nextChannel = channelList[nextIndex]+ if (!shouldPreloadAdjacentChannel(nextChannel.streamUrl, StalkerUrlFactory::isInternalStreamUrl)) {+ playerEngine.preload(null)+ return+ }viewModelScope.launch {val streamInfo = resolvePlaybackStreamInfo(nextChannel.streamUrl,diff --git a/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsTest.ktindex 20e2edc6..39fac0a7 100644--- a/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsTest.kt+++ b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsTest.kt@@ -65,4 +65,24 @@ class PlayerZapActionsTest {assertThat(calls).containsExactly("stopPlayback", "stopLiveTimeshift", "clearPreload").inOrder()}++ @Test+ fun `shouldPreloadAdjacentChannel skips Stalker internal streams`() {+ val shouldPreload = shouldPreloadAdjacentChannel(+ streamUrl = "stalker://1/live/99?cmd=ffmpeg%20http%3A%2F%2Fportal.example.com%2Fch%2F99",+ isStalkerInternalUrl = { it.startsWith("stalker://") }+ )++ assertThat(shouldPreload).isFalse()+ }++ @Test+ fun `shouldPreloadAdjacentChannel allows regular streams`() {+ val shouldPreload = shouldPreloadAdjacentChannel(+ streamUrl = "http://cdn.example.com/live/stream.ts",+ isStalkerInternalUrl = { it.startsWith("stalker://") }+ )++ assertThat(shouldPreload).isTrue()+ }}