forked from recloudstream/cloudstream
bug fix
This commit is contained in:
parent
2fbdd058f4
commit
850be93a8b
4 changed files with 259 additions and 193 deletions
|
@ -157,8 +157,14 @@ interface LoadResponse {
|
|||
val plot: String?
|
||||
}
|
||||
|
||||
fun LoadResponse.isEpisodeBased(): Boolean {
|
||||
return this is AnimeLoadResponse || this is TvSeriesLoadResponse
|
||||
fun LoadResponse?.isEpisodeBased(): Boolean {
|
||||
if (this == null) return false
|
||||
return (this is AnimeLoadResponse || this is TvSeriesLoadResponse) && (this.type == TvType.TvSeries || this.type == TvType.Anime)
|
||||
}
|
||||
|
||||
fun LoadResponse?.isAnimeBased(): Boolean {
|
||||
if (this == null) return false
|
||||
return (this.type == TvType.Anime || this.type == TvType.ONA) // && (this is AnimeLoadResponse)
|
||||
}
|
||||
|
||||
data class AnimeLoadResponse(
|
||||
|
|
|
@ -483,6 +483,10 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun View.setVis(visible: Boolean) {
|
||||
this.visibility = if (visible) VISIBLE else GONE
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun changeSkip(position: Long? = null) {
|
||||
val data = localData
|
||||
|
@ -502,17 +506,20 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
val nextEp = percentage >= OPENING_PROCENTAGE
|
||||
val isAnime =
|
||||
data.isAnimeBased()//(data is AnimeLoadResponse && (data.type == TvType.Anime || data.type == TvType.ONA))
|
||||
|
||||
skip_op_text.text = if (nextEp) "Next Episode" else "Skip OP"
|
||||
val isVis =
|
||||
if (nextEp) hasNext //&& !isCurrentlySkippingEp
|
||||
else (data is AnimeLoadResponse && (data.type == TvType.Anime || data.type == TvType.ONA))
|
||||
skip_op.visibility = if (isVis) View.VISIBLE else View.GONE
|
||||
skip_op.setVis(isAnime && !nextEp)
|
||||
skip_episode.setVis((!isAnime || nextEp) && hasNext)
|
||||
} else {
|
||||
if (data is AnimeLoadResponse) {
|
||||
val isVis = ((data.type == TvType.Anime || data.type == TvType.ONA))
|
||||
skip_op_text.text = "Skip OP"
|
||||
skip_op.visibility = if (isVis) View.VISIBLE else View.GONE
|
||||
val isAnime = data.isAnimeBased()
|
||||
|
||||
if (isAnime) {
|
||||
skip_op.setVis(true)
|
||||
skip_episode.setVis(false)
|
||||
} else {
|
||||
skip_episode.setVis(data.isEpisodeBased())
|
||||
skip_op.setVis(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -530,9 +537,23 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
private var hasUsedFirstRender = false
|
||||
|
||||
private fun savePositionInPlayer() {
|
||||
if (this::exoPlayer.isInitialized) {
|
||||
isPlayerPlaying = exoPlayer.playWhenReady
|
||||
playbackPosition = exoPlayer.currentPosition
|
||||
currentWindow = exoPlayer.currentWindowIndex
|
||||
}
|
||||
}
|
||||
|
||||
private fun safeReleasePlayer() {
|
||||
if (this::exoPlayer.isInitialized) {
|
||||
exoPlayer.release()
|
||||
}
|
||||
isCurrentlyPlaying = false
|
||||
}
|
||||
|
||||
private fun releasePlayer() {
|
||||
savePos()
|
||||
isCurrentlyPlaying = false
|
||||
val alphaAnimation = AlphaAnimation(0f, 1f)
|
||||
alphaAnimation.duration = 100
|
||||
alphaAnimation.fillAfter = true
|
||||
|
@ -540,12 +561,8 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
overlay_loading_skip_button?.visibility = VISIBLE
|
||||
loading_overlay?.startAnimation(alphaAnimation)
|
||||
if (this::exoPlayer.isInitialized) {
|
||||
isPlayerPlaying = exoPlayer.playWhenReady
|
||||
playbackPosition = exoPlayer.currentPosition
|
||||
currentWindow = exoPlayer.currentWindowIndex
|
||||
exoPlayer.release()
|
||||
}
|
||||
savePositionInPlayer()
|
||||
safeReleasePlayer()
|
||||
}
|
||||
|
||||
private class SettingsContentObserver(handler: Handler?, val activity: Activity) : ContentObserver(handler) {
|
||||
|
@ -615,6 +632,7 @@ class PlayerFragment : Fragment() {
|
|||
//next_episode_btt.isClickable = isClick
|
||||
playback_speed_btt.isClickable = isClick
|
||||
skip_op.isClickable = isClick
|
||||
skip_episode.isClickable = isClick
|
||||
resize_player.isClickable = isClick
|
||||
exo_progress.isEnabled = isClick
|
||||
player_media_route_button.isEnabled = isClick
|
||||
|
@ -815,7 +833,7 @@ class PlayerFragment : Fragment() {
|
|||
MediaStatus.REPEAT_MODE_REPEAT_SINGLE
|
||||
)*/
|
||||
// activity?.popCurrentPage(isInPlayer = true, isInExpandedView = false, isInResults = false)
|
||||
releasePlayer()
|
||||
safeReleasePlayer()
|
||||
activity?.popCurrentPage()
|
||||
}
|
||||
}
|
||||
|
@ -980,10 +998,7 @@ class PlayerFragment : Fragment() {
|
|||
video_title.startAnimation(fadeAnimation)
|
||||
|
||||
// BOTTOM
|
||||
resize_player.startAnimation(fadeAnimation)
|
||||
playback_speed_btt.startAnimation(fadeAnimation)
|
||||
sources_btt.startAnimation(fadeAnimation)
|
||||
skip_op.startAnimation(fadeAnimation)
|
||||
lock_holder.startAnimation(fadeAnimation)
|
||||
video_go_back_holder2.startAnimation(fadeAnimation)
|
||||
|
||||
updateLock()
|
||||
|
@ -1103,14 +1118,13 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
|
||||
skip_op.setOnClickListener {
|
||||
if (exoPlayer.currentPosition * 100 / exoPlayer.duration >= OPENING_PROCENTAGE) {
|
||||
if (hasNextEpisode()) {
|
||||
// skip_op.visibility = View.GONE
|
||||
skipToNextEpisode()
|
||||
}
|
||||
} else {
|
||||
skipOP()
|
||||
}
|
||||
|
||||
skip_episode.setOnClickListener {
|
||||
if (hasNextEpisode()) {
|
||||
skipToNextEpisode()
|
||||
}
|
||||
}
|
||||
|
||||
changeSkip()
|
||||
|
@ -1177,7 +1191,8 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
private fun skipToNextEpisode() {
|
||||
if (isCurrentlySkippingEp) return
|
||||
releasePlayer()
|
||||
savePos()
|
||||
safeReleasePlayer()
|
||||
isCurrentlySkippingEp = true
|
||||
val copy = playerData.copy(episodeIndex = playerData.episodeIndex + 1)
|
||||
playerData = copy
|
||||
|
@ -1224,7 +1239,10 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
super.onDestroy()
|
||||
isInPlayer = false
|
||||
releasePlayer()
|
||||
|
||||
savePos()
|
||||
savePositionInPlayer()
|
||||
safeReleasePlayer()
|
||||
|
||||
UIHelper.onAudioFocusEvent -= ::handlePauseEvent
|
||||
|
||||
|
|
|
@ -146,8 +146,8 @@ class SearchFragment : Fragment() {
|
|||
}
|
||||
allApi.providersActive = requireActivity().getApiSettings()
|
||||
|
||||
searchViewModel.search("iron man")
|
||||
// (activity as AppCompatActivity).loadResult("https://shiro.is/overlord-dubbed", "overlord-dubbed", "Shiro")
|
||||
//searchViewModel.search("iron man")
|
||||
(activity as AppCompatActivity).loadResult("https://shiro.is/overlord-dubbed", "overlord-dubbed", "Shiro")
|
||||
/*
|
||||
(requireActivity() as AppCompatActivity).supportFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.enter_anim,
|
||||
|
|
|
@ -417,7 +417,7 @@
|
|||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:paddingTop="10dp"
|
||||
|
@ -436,7 +436,7 @@
|
|||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/lock_player"
|
||||
card_view:cardElevation="0dp"
|
||||
|
||||
tools:visibility="gone"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -471,7 +471,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<LinearLayout android:id="@+id/lock_holder" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="match_parent">
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -483,9 +483,9 @@
|
|||
card_view:cardCornerRadius="@dimen/card_corner_radius"
|
||||
card_view:cardBackgroundColor="@color/transparent"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/resize_player"
|
||||
card_view:cardElevation="0dp"
|
||||
|
||||
android:id="@+id/resize_player"
|
||||
tools:visibility="gone"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -518,7 +518,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -566,8 +565,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -623,13 +620,12 @@
|
|||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
|
||||
card_view:cardCornerRadius="@dimen/card_corner_radius"
|
||||
card_view:cardBackgroundColor="@color/transparent"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/skip_op"
|
||||
android:visibility="gone"
|
||||
card_view:cardElevation="0dp"
|
||||
|
||||
android:id="@+id/skip_op"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -649,7 +645,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Skip OP"
|
||||
android:id="@+id/skip_op_text"
|
||||
android:gravity="start|center"
|
||||
android:paddingStart="10dp"
|
||||
|
||||
|
@ -662,6 +657,53 @@
|
|||
</TextView>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
card_view:cardCornerRadius="@dimen/card_corner_radius"
|
||||
card_view:cardBackgroundColor="@color/transparent"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
card_view:cardElevation="0dp"
|
||||
android:id="@+id/skip_episode"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_baseline_skip_next_24"
|
||||
app:tint="@android:color/white"
|
||||
android:layout_gravity="center">
|
||||
</ImageView>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Next Episode"
|
||||
|
||||
android:gravity="start|center"
|
||||
android:paddingStart="10dp"
|
||||
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:paddingEnd="10dp"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
>
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue