mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-12 21:30:30 +05:30
Merge pull request #6711 from Bnyro/master
fix: work around that some livestreams are not declared as such by NPE
This commit is contained in:
commit
9c418f9b2b
@ -49,6 +49,8 @@ data class Streams(
|
||||
val uploaderSubscriberCount: Long = 0,
|
||||
val previewFrames: List<PreviewFrames> = emptyList()
|
||||
) {
|
||||
val isLive = livestream || duration <= 0
|
||||
|
||||
fun toDownloadItems(downloadData: DownloadData): List<DownloadItem> {
|
||||
val (id, name, videoFormat, videoQuality, audioFormat, audioQuality, audioTrackLocale, subCode) = downloadData
|
||||
val items = mutableListOf<DownloadItem>()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user