mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
fix prev
This commit is contained in:
parent
7844cc7792
commit
658a6648ff
@ -757,8 +757,9 @@ class PlayerFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
private fun playVideo() {
|
||||
PlayingQueue.updateCurrent(videoId!!)
|
||||
lifecycleScope.launchWhenCreated {
|
||||
PlayingQueue.updateCurrent(videoId!!)
|
||||
|
||||
streams = try {
|
||||
RetrofitInstance.api.getStreams(videoId!!)
|
||||
} catch (e: IOException) {
|
||||
@ -866,8 +867,7 @@ class PlayerFragment : BaseFragment() {
|
||||
var position: Long? = null
|
||||
Thread {
|
||||
try {
|
||||
val watchPosition = Database.watchPositionDao().findById(videoId!!)
|
||||
position = if (watchPosition != null) watchPosition.position else null
|
||||
position = Database.watchPositionDao().findById(videoId!!)?.position
|
||||
// position is almost the end of the video => don't seek, start from beginning
|
||||
if (position!! > streams.duration!! * 1000 * 0.9) position = null
|
||||
} catch (e: Exception) {
|
||||
|
@ -37,8 +37,9 @@ class VideoOptionsBottomSheet(
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the player is running by observing the notification
|
||||
* Check whether the player is running and add queue options
|
||||
*/
|
||||
if (PlayingQueue.isNotEmpty()) {
|
||||
optionsList += context?.getString(R.string.play_next)!!
|
||||
|
@ -32,15 +32,13 @@ object PlayingQueue {
|
||||
}
|
||||
}
|
||||
|
||||
fun getPrev(): String {
|
||||
return queue[
|
||||
queue.indexOf(currentVideoId) - 1
|
||||
]
|
||||
fun getPrev(): String? {
|
||||
val index = queue.indexOf(currentVideoId)
|
||||
return if (index > 0) queue[index - 1] else null
|
||||
}
|
||||
|
||||
fun hasPrev(): Boolean {
|
||||
val currentIndex = queue.indexOf(currentVideoId)
|
||||
return queue.size > currentIndex + 1
|
||||
return queue.indexOf(currentVideoId) > 0
|
||||
}
|
||||
|
||||
fun contains(videoId: String): Boolean {
|
||||
@ -53,7 +51,7 @@ object PlayingQueue {
|
||||
|
||||
fun updateCurrent(videoId: String) {
|
||||
currentVideoId = videoId
|
||||
if (!contains(videoId)) add(videoId)
|
||||
queue.add(videoId)
|
||||
}
|
||||
|
||||
fun isNotEmpty() = queue.isNotEmpty()
|
||||
|
Loading…
Reference in New Issue
Block a user