mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
indicate that a video is live
This commit is contained in:
parent
968114a5f3
commit
5271a279f3
@ -1,3 +1,5 @@
|
||||
import java.time.Instant
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
@ -25,9 +27,8 @@ android {
|
||||
// use the date as version for debug builds
|
||||
if (variant.name == 'debug') {
|
||||
variant.outputs.each { output ->
|
||||
def date = getDate()
|
||||
output.versionCodeOverride = date
|
||||
output.versionNameOverride = date
|
||||
output.versionCodeOverride = getUnixTime()
|
||||
output.versionNameOverride = getUnixTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,8 +105,6 @@ dependencies {
|
||||
implementation libs.coil
|
||||
}
|
||||
|
||||
static def getDate() {
|
||||
def date = new Date()
|
||||
def formattedDate = date.format('yyyyMMddHH')
|
||||
return Integer.parseInt(formattedDate)
|
||||
static def getUnixTime() {
|
||||
return Instant.now().getEpochSecond()
|
||||
}
|
@ -118,6 +118,7 @@ class PlayerFragment : Fragment() {
|
||||
private var playlistId: String? = null
|
||||
private var channelId: String? = null
|
||||
private var isSubscribed: Boolean = false
|
||||
private var isLive = false
|
||||
|
||||
/**
|
||||
* for the transition
|
||||
@ -522,7 +523,6 @@ class PlayerFragment : Fragment() {
|
||||
val playbackSpeedValues =
|
||||
context?.resources?.getStringArray(R.array.playbackSpeedValues)!!
|
||||
exoPlayer.setPlaybackSpeed(playbackSpeed.toFloat())
|
||||
Log.e(TAG, playbackSpeed)
|
||||
val speedIndex = playbackSpeedValues.indexOf(playbackSpeed)
|
||||
playerBinding.speedText.text = playbackSpeeds[speedIndex]
|
||||
|
||||
@ -769,6 +769,12 @@ class PlayerFragment : Fragment() {
|
||||
// save related streams for autoplay
|
||||
relatedStreams = response.relatedStreams
|
||||
|
||||
// duration that's not greater than 0 indicates that the video is live
|
||||
if (!(response.duration!! > 0)) {
|
||||
isLive = true
|
||||
handleLiveVideo()
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
// set media sources for the player
|
||||
setResolutionAndSubtitles(response)
|
||||
@ -793,6 +799,11 @@ class PlayerFragment : Fragment() {
|
||||
run()
|
||||
}
|
||||
|
||||
private fun handleLiveVideo() {
|
||||
playerBinding.exoTime.visibility = View.GONE
|
||||
playerBinding.liveLL.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun seekToWatchPosition() {
|
||||
// seek to saved watch position if available
|
||||
val watchPositions = PreferenceHelper.getWatchPositions()
|
||||
|
@ -185,6 +185,29 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/liveLL"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="5dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/liveDiff"
|
||||
style="@style/ExoStyledControls.TimeText.Position"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView style="@style/ExoStyledControls.TimeText.Separator"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/liveIndicator"
|
||||
android:text="@string/live"
|
||||
style="@style/ExoStyledControls.TimeText.Duration" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/chapterLL"
|
||||
android:layout_width="0dp"
|
||||
|
Loading…
Reference in New Issue
Block a user