forked from recloudstream/cloudstream
not reload player on exit
This commit is contained in:
parent
95767fb523
commit
d5ed5f867a
6 changed files with 38 additions and 20 deletions
|
@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper
|
import com.fasterxml.jackson.databind.json.JsonMapper
|
||||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
|
||||||
import com.lagradost.cloudstream3.animeproviders.*
|
import com.lagradost.cloudstream3.animeproviders.*
|
||||||
import com.lagradost.cloudstream3.metaproviders.CrossTmdbProvider
|
import com.lagradost.cloudstream3.metaproviders.CrossTmdbProvider
|
||||||
import com.lagradost.cloudstream3.movieproviders.*
|
import com.lagradost.cloudstream3.movieproviders.*
|
||||||
|
@ -1004,7 +1003,7 @@ interface LoadResponse {
|
||||||
|
|
||||||
fun LoadResponse?.isEpisodeBased(): Boolean {
|
fun LoadResponse?.isEpisodeBased(): Boolean {
|
||||||
if (this == null) return false
|
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 {
|
fun LoadResponse?.isAnimeBased(): Boolean {
|
||||||
|
@ -1017,6 +1016,17 @@ fun TvType?.isEpisodeBased(): Boolean {
|
||||||
return (this == TvType.TvSeries || this == TvType.Anime)
|
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(
|
data class TorrentLoadResponse(
|
||||||
override var name: String,
|
override var name: String,
|
||||||
override var url: String,
|
override var url: String,
|
||||||
|
@ -1050,7 +1060,7 @@ data class AnimeLoadResponse(
|
||||||
override var year: Int? = null,
|
override var year: Int? = null,
|
||||||
|
|
||||||
var episodes: MutableMap<DubStatus, List<Episode>> = mutableMapOf(),
|
var episodes: MutableMap<DubStatus, List<Episode>> = mutableMapOf(),
|
||||||
var showStatus: ShowStatus? = null,
|
override var showStatus: ShowStatus? = null,
|
||||||
|
|
||||||
override var plot: String? = null,
|
override var plot: String? = null,
|
||||||
override var tags: List<String>? = null,
|
override var tags: List<String>? = null,
|
||||||
|
@ -1064,7 +1074,8 @@ data class AnimeLoadResponse(
|
||||||
override var comingSoon: Boolean = false,
|
override var comingSoon: Boolean = false,
|
||||||
override var syncData: MutableMap<String, String> = mutableMapOf(),
|
override var syncData: MutableMap<String, String> = mutableMapOf(),
|
||||||
override var posterHeaders: Map<String, String>? = null,
|
override var posterHeaders: Map<String, String>? = null,
|
||||||
) : LoadResponse
|
override var nextAiring: NextAiring? = null,
|
||||||
|
) : LoadResponse, EpisodeResponse
|
||||||
|
|
||||||
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
|
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
|
||||||
if (episodes == null) return
|
if (episodes == null) return
|
||||||
|
@ -1222,7 +1233,7 @@ data class TvSeriesLoadResponse(
|
||||||
override var year: Int? = null,
|
override var year: Int? = null,
|
||||||
override var plot: String? = null,
|
override var plot: String? = null,
|
||||||
|
|
||||||
var showStatus: ShowStatus? = null,
|
override var showStatus: ShowStatus? = null,
|
||||||
override var rating: Int? = null,
|
override var rating: Int? = null,
|
||||||
override var tags: List<String>? = null,
|
override var tags: List<String>? = null,
|
||||||
override var duration: Int? = null,
|
override var duration: Int? = null,
|
||||||
|
@ -1232,7 +1243,8 @@ data class TvSeriesLoadResponse(
|
||||||
override var comingSoon: Boolean = false,
|
override var comingSoon: Boolean = false,
|
||||||
override var syncData: MutableMap<String, String> = mutableMapOf(),
|
override var syncData: MutableMap<String, String> = mutableMapOf(),
|
||||||
override var posterHeaders: Map<String, String>? = null,
|
override var posterHeaders: Map<String, String>? = null,
|
||||||
) : LoadResponse
|
override var nextAiring: NextAiring? = null,
|
||||||
|
) : LoadResponse, EpisodeResponse
|
||||||
|
|
||||||
suspend fun MainAPI.newTvSeriesLoadResponse(
|
suspend fun MainAPI.newTvSeriesLoadResponse(
|
||||||
name: String,
|
name: String,
|
||||||
|
|
|
@ -36,11 +36,6 @@ interface SyncAPI : OAuth2API {
|
||||||
override var id: Int? = null,
|
override var id: Int? = null,
|
||||||
) : SearchResponse
|
) : SearchResponse
|
||||||
|
|
||||||
data class SyncNextAiring(
|
|
||||||
val episode: Int,
|
|
||||||
val unixTime: Long,
|
|
||||||
)
|
|
||||||
|
|
||||||
data class SyncStatus(
|
data class SyncStatus(
|
||||||
val status: Int,
|
val status: Int,
|
||||||
/** 1-10 */
|
/** 1-10 */
|
||||||
|
@ -63,7 +58,7 @@ interface SyncAPI : OAuth2API {
|
||||||
var duration: Int? = null,
|
var duration: Int? = null,
|
||||||
var synopsis: String? = null,
|
var synopsis: String? = null,
|
||||||
var airStatus: ShowStatus? = null,
|
var airStatus: ShowStatus? = null,
|
||||||
var nextAiring: SyncNextAiring? = null,
|
var nextAiring: NextAiring? = null,
|
||||||
var studio: List<String>? = null,
|
var studio: List<String>? = null,
|
||||||
var genres: List<String>? = null,
|
var genres: List<String>? = null,
|
||||||
var synonyms: List<String>? = null,
|
var synonyms: List<String>? = null,
|
||||||
|
|
|
@ -98,7 +98,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
return SyncAPI.SyncResult(
|
return SyncAPI.SyncResult(
|
||||||
season.id.toString(),
|
season.id.toString(),
|
||||||
nextAiring = season.nextAiringEpisode?.let {
|
nextAiring = season.nextAiringEpisode?.let {
|
||||||
SyncAPI.SyncNextAiring(
|
NextAiring(
|
||||||
it.episode ?: return@let null,
|
it.episode ?: return@let null,
|
||||||
(it.timeUntilAiring ?: return@let null) + unixTime
|
(it.timeUntilAiring ?: return@let null) + unixTime
|
||||||
)
|
)
|
||||||
|
|
|
@ -300,14 +300,14 @@ class CS3IPlayer : IPlayer {
|
||||||
|
|
||||||
saveData()
|
saveData()
|
||||||
exoPlayer?.pause()
|
exoPlayer?.pause()
|
||||||
releasePlayer()
|
//releasePlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
Log.i(TAG, "onPause")
|
Log.i(TAG, "onPause")
|
||||||
saveData()
|
saveData()
|
||||||
exoPlayer?.pause()
|
exoPlayer?.pause()
|
||||||
releasePlayer()
|
//releasePlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume(context: Context) {
|
override fun onResume(context: Context) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
|
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
|
||||||
import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull
|
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.IGenerator
|
||||||
import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator
|
import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator
|
||||||
import com.lagradost.cloudstream3.ui.player.SubtitleData
|
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.Coroutines.ioWork
|
||||||
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE
|
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||||
|
@ -144,6 +142,10 @@ class ResultViewModel : ViewModel() {
|
||||||
posterUrl = posterUrl ?: meta.posterUrl ?: meta.backgroundPosterUrl
|
posterUrl = posterUrl ?: meta.posterUrl ?: meta.backgroundPosterUrl
|
||||||
actors = actors ?: meta.actors
|
actors = actors ?: meta.actors
|
||||||
|
|
||||||
|
if (this is EpisodeResponse) {
|
||||||
|
nextAiring = nextAiring ?: meta.nextAiring
|
||||||
|
}
|
||||||
|
|
||||||
for ((k, v) in syncs ?: emptyMap()) {
|
for ((k, v) in syncs ?: emptyMap()) {
|
||||||
syncData[k] = v
|
syncData[k] = v
|
||||||
}
|
}
|
||||||
|
@ -162,7 +164,6 @@ class ResultViewModel : ViewModel() {
|
||||||
argamap({
|
argamap({
|
||||||
addTrailer(meta.trailers)
|
addTrailer(meta.trailers)
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
if (this !is AnimeLoadResponse) return@argamap
|
if (this !is AnimeLoadResponse) return@argamap
|
||||||
val map = getEpisodesDetails(getMalId(), getAniListId(), isResponseRequired = false)
|
val map = getEpisodesDetails(getMalId(), getAniListId(), isResponseRequired = false)
|
||||||
if (map.isNullOrEmpty()) return@argamap
|
if (map.isNullOrEmpty()) return@argamap
|
||||||
|
|
|
@ -816,6 +816,16 @@
|
||||||
tools:text="8 Episodes" />
|
tools:text="8 Episodes" />
|
||||||
</LinearLayout>
|
</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
|
<com.facebook.shimmer.ShimmerFrameLayout
|
||||||
android:id="@+id/result_episode_loading"
|
android:id="@+id/result_episode_loading"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue