diff --git a/app/src/main/java/com/github/libretube/api/obj/Streams.kt b/app/src/main/java/com/github/libretube/api/obj/Streams.kt index f56226916..d4d50cd17 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Streams.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Streams.kt @@ -49,6 +49,8 @@ data class Streams( val uploaderSubscriberCount: Long = 0, val previewFrames: List = emptyList() ) { + val isLive = livestream || duration <= 0 + fun toDownloadItems(downloadData: DownloadData): List { val (id, name, videoFormat, videoQuality, audioFormat, audioQuality, audioTrackLocale, subCode) = downloadData val items = mutableListOf() diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 39974783b..d28a9ec20 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -695,11 +695,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { binding.relPlayerDownload.setOnClickListener { if (!this::streams.isInitialized) return@setOnClickListener - if (streams.duration <= 0) { - Toast.makeText(context, R.string.cannotDownload, Toast.LENGTH_SHORT).show() - } else { - DownloadHelper.startDownloadDialog(requireContext(), childFragmentManager, videoId) - } + DownloadHelper.startDownloadDialog(requireContext(), childFragmentManager, videoId) } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { @@ -1135,8 +1131,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { R.string.subscribers, streams.uploaderSubscriberCount.formatShort() ) - player.isLive = streams.livestream - relPlayerDownload.isVisible = !streams.livestream + player.isLive = streams.isLive + relPlayerDownload.isVisible = !streams.isLive } playerBinding.exoTitle.text = streams.title @@ -1295,7 +1291,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { viewModel.player.seekTo(timeStamp * 1000) // delete the time stamp because it already got consumed timeStamp = 0L - } else if (!streams.livestream) { + } else if (!streams.isLive) { // seek to the saved watch position PlayerHelper.getStoredWatchPosition(videoId, streams.duration)?.let { viewModel.player.seekTo(it) @@ -1346,7 +1342,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { !PlayerHelper.useHlsOverDash && streams.videoStreams.isNotEmpty() -> { // only use the dash manifest generated by YT if either it's a livestream or no other source is available val dashUri = - if (streams.livestream && streams.dash != null) { + if (streams.isLive && streams.dash != null) { ProxyHelper.unwrapStreamUrl( streams.dash!! ).toUri()