mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
fix crash when videoId null
This commit is contained in:
parent
c835f5ab80
commit
485cc19023
@ -13,7 +13,7 @@ interface WatchPositionDao {
|
||||
fun getAll(): List<WatchPosition>
|
||||
|
||||
@Query("SELECT * FROM watchPosition WHERE videoId LIKE :videoId LIMIT 1")
|
||||
fun findById(videoId: String): WatchPosition
|
||||
fun findById(videoId: String): WatchPosition?
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertAll(vararg watchPositions: WatchPosition)
|
||||
|
@ -866,7 +866,8 @@ class PlayerFragment : BaseFragment() {
|
||||
var position: Long? = null
|
||||
Thread {
|
||||
try {
|
||||
position = Database.watchPositionDao().findById(videoId!!).position
|
||||
val watchPosition = Database.watchPositionDao().findById(videoId!!)
|
||||
position = if (watchPosition != null) watchPosition.position else null
|
||||
// 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) {
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.github.libretube.util
|
||||
|
||||
import android.util.Log
|
||||
import com.github.libretube.extensions.TAG
|
||||
|
||||
object PlayingQueue {
|
||||
private val queue = mutableListOf<String>()
|
||||
private var currentVideoId: String? = null
|
||||
@ -21,6 +24,7 @@ object PlayingQueue {
|
||||
|
||||
fun getNext(): String? {
|
||||
val currentIndex = queue.indexOf(currentVideoId)
|
||||
Log.e(TAG(), queue.toString())
|
||||
return if (currentIndex > queue.size) {
|
||||
null
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user