mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
show remaining time in video player & update viewmodel and lifecycle
This commit is contained in:
parent
4cc33146e3
commit
f792ec757e
2 changed files with 15 additions and 10 deletions
|
@ -159,10 +159,10 @@ dependencies {
|
|||
// Android Core & Lifecycle
|
||||
implementation("androidx.core:core-ktx:1.12.0")
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.5")
|
||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2")
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
|
||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.5")
|
||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.6")
|
||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
|
||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.6")
|
||||
|
||||
// Design & UI
|
||||
implementation("jp.wasabeef:glide-transformations:4.3.0")
|
||||
|
@ -224,8 +224,8 @@ dependencies {
|
|||
Level 25 or Less. */
|
||||
|
||||
// Downloading & Networking
|
||||
implementation("androidx.work:work-runtime:2.8.1")
|
||||
implementation("androidx.work:work-runtime-ktx:2.8.1")
|
||||
implementation("androidx.work:work-runtime:2.9.0")
|
||||
implementation("androidx.work:work-runtime-ktx:2.9.0")
|
||||
implementation("com.github.Blatzar:NiceHttp:0.4.4") // HTTP Lib
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.lagradost.cloudstream3.ui.player.GeneratorPlayer.Companion.subsProvid
|
|||
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper
|
||||
import com.lagradost.cloudstream3.ui.result.setText
|
||||
import com.lagradost.cloudstream3.ui.result.txt
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.isUsingMobileData
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||
|
@ -79,7 +80,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
|||
protected open var isTv = false
|
||||
protected var playerBinding: PlayerCustomLayoutBinding? = null
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var isRemainingTimeEnabled = false
|
||||
private var isShowTimeRemaining = false
|
||||
|
||||
// state of player UI
|
||||
protected var isShowing = false
|
||||
|
@ -1423,7 +1424,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
|||
}
|
||||
|
||||
exoDuration.setOnClickListener {
|
||||
if (!isRemainingTimeEnabled) {
|
||||
if (!isShowTimeRemaining) {
|
||||
startUpdatingRemainingTime()
|
||||
} else {
|
||||
stopUpdatingRemainingTime()
|
||||
|
@ -1521,6 +1522,10 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
|||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
|
||||
if (SettingsFragment.isTrueTvSettings()) {
|
||||
startUpdatingRemainingTime() // cs3 is an ott platform itself
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
|
@ -1545,7 +1550,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
|||
val formattedTime = "-${DateUtils.formatElapsedTime(remainingTimeSeconds)}"
|
||||
|
||||
playerBinding?.exoDuration?.text = formattedTime
|
||||
isRemainingTimeEnabled = true
|
||||
isShowTimeRemaining = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1562,7 +1567,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
|||
handler.removeCallbacksAndMessages(null)
|
||||
val totalDuration = player.getDuration()?.div(1000)
|
||||
playerBinding?.exoDuration?.text = totalDuration?.let { DateUtils.formatElapsedTime(it) }
|
||||
isRemainingTimeEnabled = false
|
||||
isShowTimeRemaining = false
|
||||
}
|
||||
|
||||
private fun dynamicOrientation(): Int {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue