not reload player on exit

This commit is contained in:
LagradOst 2022-06-20 15:17:34 +02:00
parent 95767fb523
commit d5ed5f867a
6 changed files with 38 additions and 20 deletions

View file

@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.animeproviders.*
import com.lagradost.cloudstream3.metaproviders.CrossTmdbProvider
import com.lagradost.cloudstream3.movieproviders.*
@ -899,11 +898,11 @@ interface LoadResponse {
this.actors = actors?.map { actor -> ActorData(actor) }
}
fun LoadResponse.getMalId() : String? {
fun LoadResponse.getMalId(): String? {
return this.syncData[malIdPrefix]
}
fun LoadResponse.getAniListId() : String? {
fun LoadResponse.getAniListId(): String? {
return this.syncData[aniListIdPrefix]
}
@ -1004,7 +1003,7 @@ interface LoadResponse {
fun LoadResponse?.isEpisodeBased(): Boolean {
if (this == null) return false
return (this is AnimeLoadResponse || this is TvSeriesLoadResponse) && this.type.isEpisodeBased()
return this is EpisodeResponse && this.type.isEpisodeBased()
}
fun LoadResponse?.isAnimeBased(): Boolean {
@ -1017,6 +1016,17 @@ fun TvType?.isEpisodeBased(): Boolean {
return (this == TvType.TvSeries || this == TvType.Anime)
}
data class NextAiring(
val episode: Int,
val unixTime: Long,
)
interface EpisodeResponse {
var showStatus: ShowStatus?
var nextAiring: NextAiring?
}
data class TorrentLoadResponse(
override var name: String,
override var url: String,
@ -1050,7 +1060,7 @@ data class AnimeLoadResponse(
override var year: Int? = null,
var episodes: MutableMap<DubStatus, List<Episode>> = mutableMapOf(),
var showStatus: ShowStatus? = null,
override var showStatus: ShowStatus? = null,
override var plot: String? = null,
override var tags: List<String>? = null,
@ -1064,7 +1074,8 @@ data class AnimeLoadResponse(
override var comingSoon: Boolean = false,
override var syncData: MutableMap<String, String> = mutableMapOf(),
override var posterHeaders: Map<String, String>? = null,
) : LoadResponse
override var nextAiring: NextAiring? = null,
) : LoadResponse, EpisodeResponse
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
if (episodes == null) return
@ -1222,7 +1233,7 @@ data class TvSeriesLoadResponse(
override var year: Int? = null,
override var plot: String? = null,
var showStatus: ShowStatus? = null,
override var showStatus: ShowStatus? = null,
override var rating: Int? = null,
override var tags: List<String>? = null,
override var duration: Int? = null,
@ -1232,7 +1243,8 @@ data class TvSeriesLoadResponse(
override var comingSoon: Boolean = false,
override var syncData: MutableMap<String, String> = mutableMapOf(),
override var posterHeaders: Map<String, String>? = null,
) : LoadResponse
override var nextAiring: NextAiring? = null,
) : LoadResponse, EpisodeResponse
suspend fun MainAPI.newTvSeriesLoadResponse(
name: String,

View file

@ -36,11 +36,6 @@ interface SyncAPI : OAuth2API {
override var id: Int? = null,
) : SearchResponse
data class SyncNextAiring(
val episode: Int,
val unixTime: Long,
)
data class SyncStatus(
val status: Int,
/** 1-10 */
@ -63,7 +58,7 @@ interface SyncAPI : OAuth2API {
var duration: Int? = null,
var synopsis: String? = null,
var airStatus: ShowStatus? = null,
var nextAiring: SyncNextAiring? = null,
var nextAiring: NextAiring? = null,
var studio: List<String>? = null,
var genres: List<String>? = null,
var synonyms: List<String>? = null,

View file

@ -98,7 +98,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
return SyncAPI.SyncResult(
season.id.toString(),
nextAiring = season.nextAiringEpisode?.let {
SyncAPI.SyncNextAiring(
NextAiring(
it.episode ?: return@let null,
(it.timeUntilAiring ?: return@let null) + unixTime
)

View file

@ -300,14 +300,14 @@ class CS3IPlayer : IPlayer {
saveData()
exoPlayer?.pause()
releasePlayer()
//releasePlayer()
}
override fun onPause() {
Log.i(TAG, "onPause")
saveData()
exoPlayer?.pause()
releasePlayer()
//releasePlayer()
}
override fun onResume(context: Context) {

View file

@ -5,7 +5,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull
@ -29,7 +28,6 @@ import com.lagradost.cloudstream3.ui.WatchType
import com.lagradost.cloudstream3.ui.player.IGenerator
import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator
import com.lagradost.cloudstream3.ui.player.SubtitleData
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import com.lagradost.cloudstream3.utils.Coroutines.ioWork
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE
import com.lagradost.cloudstream3.utils.DataStoreHelper
@ -144,6 +142,10 @@ class ResultViewModel : ViewModel() {
posterUrl = posterUrl ?: meta.posterUrl ?: meta.backgroundPosterUrl
actors = actors ?: meta.actors
if (this is EpisodeResponse) {
nextAiring = nextAiring ?: meta.nextAiring
}
for ((k, v) in syncs ?: emptyMap()) {
syncData[k] = v
}
@ -162,7 +164,6 @@ class ResultViewModel : ViewModel() {
argamap({
addTrailer(meta.trailers)
}, {
if (this !is AnimeLoadResponse) return@argamap
val map = getEpisodesDetails(getMalId(), getAniListId(), isResponseRequired = false)
if (map.isNullOrEmpty()) return@argamap

View file

@ -816,6 +816,16 @@
tools:text="8 Episodes" />
</LinearLayout>
<!--TODO add next airing-->
<TextView
android:visibility="gone"
android:id="@+id/result_next_airing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/textColor"
android:textSize="17sp"
android:textStyle="bold"
tools:text="Episode 1022 will be released in" />
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/result_episode_loading"
android:layout_width="match_parent"