indicate time difference

This commit is contained in:
Bnyro 2022-07-30 13:36:06 +02:00
parent 11b568d0b6
commit 3dfd0ba562
2 changed files with 16 additions and 5 deletions

View File

@ -19,6 +19,7 @@ import android.os.PowerManager
import android.support.v4.media.session.MediaSessionCompat
import android.text.Html
import android.text.TextUtils
import android.text.format.DateUtils
import android.util.Log
import android.view.LayoutInflater
import android.view.MotionEvent
@ -1020,9 +1021,18 @@ class PlayerFragment : Fragment() {
)
// switch back to normal speed when on the end of live stream
if (isLive && (exoPlayer.duration - exoPlayer.duration < 0.5)) {
Log.e(exoPlayer.duration.toString(), exoPlayer.currentPosition.toString())
if (isLive && (exoPlayer.duration - exoPlayer.currentPosition < 10000)) {
exoPlayer.setPlaybackSpeed(1F)
playerBinding.speedText.text = "1x"
playerBinding.liveSeparator.visibility = View.GONE
playerBinding.liveDiff.text = ""
} else if (isLive) {
Log.e(TAG, "changing the time")
// live stream but not watching at the end/live position
playerBinding.liveSeparator.visibility = View.VISIBLE
val diffText = DateUtils.formatElapsedTime((exoPlayer.duration - exoPlayer.currentPosition) / 1000)
playerBinding.liveDiff.text = "-$diffText"
}
// check if video has ended, next video is available and autoplay is enabled.
else if (

View File

@ -195,16 +195,17 @@
<TextView
android:id="@+id/liveDiff"
style="@style/ExoStyledControls.TimeText.Position"
android:visibility="gone"/>
style="@style/ExoStyledControls.TimeText.Duration" />
<TextView style="@style/ExoStyledControls.TimeText.Separator"
<TextView
android:id="@+id/liveSeparator"
style="@style/ExoStyledControls.TimeText.Separator"
android:visibility="gone"/>
<TextView
android:id="@+id/liveIndicator"
android:text="@string/live"
style="@style/ExoStyledControls.TimeText.Duration" />
style="@style/ExoStyledControls.TimeText.Position" />
</LinearLayout>