mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
player UI
This commit is contained in:
parent
5e5e4a4ca5
commit
3ef1c28fbb
4 changed files with 177 additions and 49 deletions
|
@ -2,11 +2,13 @@ package com.lagradost.cloudstream3.ui.player
|
|||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context.AUDIO_SERVICE
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.database.ContentObserver
|
||||
import android.graphics.Color
|
||||
import android.media.AudioManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
|
@ -14,8 +16,7 @@ import android.os.Handler
|
|||
import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.View.*
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AlphaAnimation
|
||||
import android.view.animation.Animation
|
||||
|
@ -23,6 +24,7 @@ import android.view.animation.AnimationUtils
|
|||
import android.widget.ProgressBar
|
||||
import android.widget.Toast
|
||||
import android.widget.Toast.LENGTH_LONG
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.preference.PreferenceManager
|
||||
|
@ -102,6 +104,8 @@ class PlayerFragment : Fragment() {
|
|||
private var isLoading = true
|
||||
private lateinit var exoPlayer: SimpleExoPlayer
|
||||
|
||||
private var isLocked = false
|
||||
|
||||
private lateinit var settingsManager: SharedPreferences
|
||||
|
||||
private fun seekTime(time: Long) {
|
||||
|
@ -162,11 +166,47 @@ class PlayerFragment : Fragment() {
|
|||
AspectRatioFrameLayout.RESIZE_MODE_ZOOM,
|
||||
)
|
||||
|
||||
private fun updateLock() {
|
||||
video_locked_img.setImageResource(if (isLocked) R.drawable.video_locked else R.drawable.video_unlocked)
|
||||
val color = if (isLocked) ContextCompat.getColor(requireContext(), R.color.videoColorPrimary)
|
||||
else Color.WHITE
|
||||
|
||||
video_locked_text.setTextColor(color)
|
||||
video_locked_img.setColorFilter(color)
|
||||
|
||||
val isClick = !isLocked
|
||||
println("UPDATED LOCK $isClick")
|
||||
exo_play.isClickable = isClick
|
||||
exo_pause.isClickable = isClick
|
||||
exo_ffwd.isClickable = isClick
|
||||
exo_rew.isClickable = isClick
|
||||
exo_prev.isClickable = isClick
|
||||
video_go_back.isClickable = isClick
|
||||
exo_progress.isClickable = isClick
|
||||
//next_episode_btt.isClickable = isClick
|
||||
playback_speed_btt.isClickable = isClick
|
||||
skip_op.isClickable = isClick
|
||||
resize_player.isClickable = isClick
|
||||
exo_progress.isEnabled = isClick
|
||||
|
||||
// Clickable doesn't seem to work on com.google.android.exoplayer2.ui.DefaultTimeBar
|
||||
//exo_progress.visibility = if (isLocked) INVISIBLE else VISIBLE
|
||||
|
||||
val fadeTo = if (!isLocked) 1f else 0f
|
||||
val fadeAnimation = AlphaAnimation(1f - fadeTo, fadeTo)
|
||||
|
||||
fadeAnimation.duration = 100
|
||||
fadeAnimation.fillAfter = true
|
||||
|
||||
shadow_overlay.startAnimation(fadeAnimation)
|
||||
}
|
||||
|
||||
private var resizeMode = 0
|
||||
private var playbackSpeed = 0f
|
||||
private var allEpisodes: HashMap<Int, ArrayList<ExtractorLink>> = HashMap()
|
||||
private var episodes: ArrayList<ResultEpisode> = ArrayList()
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
@ -247,7 +287,7 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
exo_rew_text.text = "$fastForwardTime"
|
||||
exo_rew_text.post { exo_rew_text.text = "$fastForwardTime" }
|
||||
}
|
||||
})
|
||||
exo_rew_text.startAnimation(goLeft)
|
||||
|
@ -258,8 +298,47 @@ class PlayerFragment : Fragment() {
|
|||
exo_ffwd.setOnClickListener {
|
||||
val rotateRight = AnimationUtils.loadAnimation(context, R.anim.rotate_right)
|
||||
exo_ffwd.startAnimation(rotateRight)
|
||||
|
||||
val goRight = AnimationUtils.loadAnimation(context, R.anim.go_right)
|
||||
goRight.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
exo_ffwd_text.post { exo_ffwd_text.text = "$fastForwardTime" }
|
||||
}
|
||||
})
|
||||
exo_ffwd_text.startAnimation(goRight)
|
||||
exo_ffwd_text.text = "+$fastForwardTime"
|
||||
seekTime(fastForwardTime * 1000L)
|
||||
}
|
||||
|
||||
|
||||
lock_player.setOnClickListener {
|
||||
isLocked = !isLocked
|
||||
val fadeTo = if (isLocked) 0f else 1f
|
||||
|
||||
val fadeAnimation = AlphaAnimation(1f - fadeTo, fadeTo)
|
||||
fadeAnimation.duration = 100
|
||||
// fadeAnimation.startOffset = 100
|
||||
fadeAnimation.fillAfter = true
|
||||
|
||||
// MENUS
|
||||
centerMenu.startAnimation(fadeAnimation)
|
||||
//video_bar.startAnimation(fadeAnimation)
|
||||
|
||||
// BOTTOM
|
||||
resize_player.startAnimation(fadeAnimation)
|
||||
playback_speed_btt.startAnimation(fadeAnimation)
|
||||
sources_btt.startAnimation(fadeAnimation)
|
||||
skip_op.startAnimation(fadeAnimation)
|
||||
|
||||
updateLock()
|
||||
}
|
||||
}
|
||||
|
||||
fun getCurrentUrl(): ExtractorLink {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
>
|
||||
<translate
|
||||
android:fromXDelta="0"
|
||||
android:toXDelta="-200"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="-30%"
|
||||
android:duration="200"
|
||||
>
|
||||
</translate>
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
>
|
||||
<translate
|
||||
android:fromXDelta="0"
|
||||
android:toXDelta="100"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="30%"
|
||||
android:duration="200"
|
||||
>
|
||||
</translate>
|
||||
</set>
|
|
@ -13,7 +13,7 @@
|
|||
android:id="@+id/shadow_overlay"
|
||||
android:background="@color/black_overlay"
|
||||
/>
|
||||
|
||||
<!--
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
|
@ -46,7 +46,7 @@
|
|||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
-->
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
|
@ -116,6 +116,7 @@
|
|||
tools:text="Hello world"
|
||||
>
|
||||
</TextView>
|
||||
<!--
|
||||
<LinearLayout
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
|
@ -161,7 +162,7 @@
|
|||
|
||||
</ImageView>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
</LinearLayout>-->
|
||||
<FrameLayout
|
||||
android:layout_margin="5dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -202,7 +203,6 @@
|
|||
>
|
||||
|
||||
<FrameLayout android:layout_width="wrap_content"
|
||||
android:layout_marginEnd="140dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content" tools:ignore="RtlSymmetry">
|
||||
<TextView
|
||||
|
@ -212,13 +212,14 @@
|
|||
android:textSize="19sp"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:textFontWeight="900"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="40dp">
|
||||
</TextView>
|
||||
<ImageButton
|
||||
android:paddingLeft="100dp"
|
||||
android:id="@id/exo_rew"
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="70dp"
|
||||
|
@ -258,7 +259,6 @@
|
|||
|
||||
|
||||
<FrameLayout android:layout_width="wrap_content"
|
||||
android:layout_marginStart="140dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
|
@ -269,7 +269,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:layout_width="40dp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="40dp">
|
||||
</TextView>
|
||||
<ImageButton
|
||||
|
@ -341,6 +341,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/video_bar"
|
||||
>
|
||||
|
||||
|
||||
|
@ -397,6 +398,54 @@
|
|||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
>
|
||||
<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"
|
||||
android:id="@+id/lock_player"
|
||||
card_view:cardElevation="0dp"
|
||||
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:id="@+id/video_locked_img"
|
||||
android:src="@drawable/video_locked"
|
||||
app:tint="@android:color/white"
|
||||
android:layout_gravity="center">
|
||||
|
||||
</ImageView>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Lock"
|
||||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/video_locked_text"
|
||||
android:textColor="@android:color/white"
|
||||
>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
|
@ -446,18 +495,17 @@
|
|||
</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"
|
||||
app:cardCornerRadius="@dimen/card_corner_radius"
|
||||
app:cardBackgroundColor="@color/transparent"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/playback_speed_btt"
|
||||
card_view:cardElevation="0dp"
|
||||
app:cardElevation="0dp"
|
||||
|
||||
>
|
||||
<LinearLayout
|
||||
|
@ -476,7 +524,7 @@
|
|||
|
||||
</ImageView>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Speed"
|
||||
android:gravity="center"
|
||||
|
|
Loading…
Reference in a new issue