forked from recloudstream/cloudstream
Fix chromecasting regression
This commit is contained in:
parent
27344abbec
commit
060d983d2e
2 changed files with 18 additions and 12 deletions
|
@ -10,6 +10,7 @@ import android.util.Log
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.MainThread
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
|
@ -26,6 +27,7 @@ import org.schabi.newpipe.extractor.NewPipe
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object CommonActivity {
|
object CommonActivity {
|
||||||
|
@MainThread
|
||||||
fun Activity?.getCastSession(): CastSession? {
|
fun Activity?.getCastSession(): CastSession? {
|
||||||
return (this as MainActivity?)?.mSessionManager?.currentCastSession
|
return (this as MainActivity?)?.mSessionManager?.currentCastSession
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.isConnectedToChromecast
|
||||||
import com.lagradost.cloudstream3.utils.CastHelper.startCast
|
import com.lagradost.cloudstream3.utils.CastHelper.startCast
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioWork
|
import com.lagradost.cloudstream3.utils.Coroutines.ioWork
|
||||||
|
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getDub
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getDub
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getResultEpisode
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getResultEpisode
|
||||||
|
@ -798,18 +799,21 @@ class ResultViewModel2 : ViewModel() {
|
||||||
val response = currentResponse ?: return
|
val response = currentResponse ?: return
|
||||||
val eps = currentEpisodes[currentIndex ?: return] ?: return
|
val eps = currentEpisodes[currentIndex ?: return] ?: return
|
||||||
|
|
||||||
activity.getCastSession()?.startCast(
|
// Main needed because getCastSession needs to be on main thread
|
||||||
response.apiName,
|
main {
|
||||||
response.isMovie(),
|
activity.getCastSession()?.startCast(
|
||||||
response.name,
|
response.apiName,
|
||||||
response.posterUrl,
|
response.isMovie(),
|
||||||
result.index,
|
response.name,
|
||||||
eps,
|
response.posterUrl,
|
||||||
links,
|
result.index,
|
||||||
subs,
|
eps,
|
||||||
startTime = result.getRealPosition(),
|
links,
|
||||||
startIndex = startIndex
|
subs,
|
||||||
)
|
startTime = result.getRealPosition(),
|
||||||
|
startIndex = startIndex
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cancelLinks() {
|
fun cancelLinks() {
|
||||||
|
|
Loading…
Reference in a new issue