Skip to content

Commit

Permalink
fix detecting end on stream downloads
Browse files Browse the repository at this point in the history
(cherry picked from commit b3f4fdc)
  • Loading branch information
crackededed committed Jul 3, 2024
1 parent 00b564e commit 481b3ec
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
minSdk = 16
targetSdk = 34
versionCode = 121
versionName = "2.33.0"
versionName = "2.33.1"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,14 @@ class StreamDownloadWorker @AssistedInject constructor(
}
jobs.awaitAll()
collector.cancel()
if (playlist.end) {
return@withContext true
}
} else {
return@withContext false
return@withContext true
}
} else {
return@withContext false
return@withContext true
}
}
val timeTaken = System.currentTimeMillis() - startTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ data class MediaPlaylist(
val targetDuration: Int,
val dateRanges: List<DateRange>,
val initSegmentUri: String?,
val segments: List<Segment>
val segments: List<Segment>,
val end: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ object PlaylistUtils {
var initSegmentUri: String? = null
val segments = mutableListOf<Segment>()
var segmentInfo: Pair<Float, String?>? = null
var end = false
input.bufferedReader().forEachLine { line ->
if (line.isNotBlank()) {
if (line.startsWith('#')) {
Expand Down Expand Up @@ -58,6 +59,9 @@ object PlaylistUtils {
}
}
}
line.startsWith("#EXT-X-ENDLIST") -> {
end = true
}
}
} else {
segmentInfo?.let {
Expand All @@ -67,7 +71,7 @@ object PlaylistUtils {
}
}
}
return MediaPlaylist(targetDuration, dateRanges, initSegmentUri, segments)
return MediaPlaylist(targetDuration, dateRanges, initSegmentUri, segments, end)
}

fun writeMediaPlaylist(playlist: MediaPlaylist, output: OutputStream) {
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
android-gradle-plugin = "8.5.0"
apollo = "3.8.4"
appcompat = "1.7.0"
checker-qual = "3.44.0"
checker-qual = "3.45.0"
coil = "2.6.0"
constraintlayout = "2.1.4"
core = "1.13.1"
Expand All @@ -18,7 +18,7 @@ hilt-extension-compiler = "1.2.0"
hilt-work = "1.2.0"
kotlin = "2.0.0"
ksp = "2.0.0-1.0.22"
lifecycle = "2.8.2"
lifecycle = "2.8.3"
material = "1.12.0"
media3 = "1.3.1"
navigation = "2.7.7"
Expand Down

0 comments on commit 481b3ec

Please sign in to comment.