indicate that a video is live

This commit is contained in:
Bnyro 2022-07-30 13:09:57 +02:00
parent 968114a5f3
commit 5271a279f3
3 changed files with 41 additions and 8 deletions

View File

@ -1,3 +1,5 @@
import java.time.Instant
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'kotlin-android' id 'kotlin-android'
@ -25,9 +27,8 @@ android {
// use the date as version for debug builds // use the date as version for debug builds
if (variant.name == 'debug') { if (variant.name == 'debug') {
variant.outputs.each { output -> variant.outputs.each { output ->
def date = getDate() output.versionCodeOverride = getUnixTime()
output.versionCodeOverride = date output.versionNameOverride = getUnixTime()
output.versionNameOverride = date
} }
} }
} }
@ -104,8 +105,6 @@ dependencies {
implementation libs.coil implementation libs.coil
} }
static def getDate() { static def getUnixTime() {
def date = new Date() return Instant.now().getEpochSecond()
def formattedDate = date.format('yyyyMMddHH')
return Integer.parseInt(formattedDate)
} }

View File

@ -118,6 +118,7 @@ class PlayerFragment : Fragment() {
private var playlistId: String? = null private var playlistId: String? = null
private var channelId: String? = null private var channelId: String? = null
private var isSubscribed: Boolean = false private var isSubscribed: Boolean = false
private var isLive = false
/** /**
* for the transition * for the transition
@ -522,7 +523,6 @@ class PlayerFragment : Fragment() {
val playbackSpeedValues = val playbackSpeedValues =
context?.resources?.getStringArray(R.array.playbackSpeedValues)!! context?.resources?.getStringArray(R.array.playbackSpeedValues)!!
exoPlayer.setPlaybackSpeed(playbackSpeed.toFloat()) exoPlayer.setPlaybackSpeed(playbackSpeed.toFloat())
Log.e(TAG, playbackSpeed)
val speedIndex = playbackSpeedValues.indexOf(playbackSpeed) val speedIndex = playbackSpeedValues.indexOf(playbackSpeed)
playerBinding.speedText.text = playbackSpeeds[speedIndex] playerBinding.speedText.text = playbackSpeeds[speedIndex]
@ -769,6 +769,12 @@ class PlayerFragment : Fragment() {
// save related streams for autoplay // save related streams for autoplay
relatedStreams = response.relatedStreams relatedStreams = response.relatedStreams
// duration that's not greater than 0 indicates that the video is live
if (!(response.duration!! > 0)) {
isLive = true
handleLiveVideo()
}
runOnUiThread { runOnUiThread {
// set media sources for the player // set media sources for the player
setResolutionAndSubtitles(response) setResolutionAndSubtitles(response)
@ -793,6 +799,11 @@ class PlayerFragment : Fragment() {
run() run()
} }
private fun handleLiveVideo() {
playerBinding.exoTime.visibility = View.GONE
playerBinding.liveLL.visibility = View.VISIBLE
}
private fun seekToWatchPosition() { private fun seekToWatchPosition() {
// seek to saved watch position if available // seek to saved watch position if available
val watchPositions = PreferenceHelper.getWatchPositions() val watchPositions = PreferenceHelper.getWatchPositions()

View File

@ -185,6 +185,29 @@
</LinearLayout> </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 <LinearLayout
android:id="@+id/chapterLL" android:id="@+id/chapterLL"
android:layout_width="0dp" android:layout_width="0dp"