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