mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
player UI stuff
This commit is contained in:
parent
3d2f00313b
commit
5e5e4a4ca5
11 changed files with 188 additions and 38 deletions
|
@ -1,7 +1,10 @@
|
|||
package com.lagradost.cloudstream3.ui.player
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
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.media.AudioManager
|
||||
|
@ -15,6 +18,8 @@ import android.view.View.GONE
|
|||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AlphaAnimation
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.Toast
|
||||
import android.widget.Toast.LENGTH_LONG
|
||||
|
@ -49,6 +54,7 @@ import javax.net.ssl.SSLContext
|
|||
import javax.net.ssl.SSLSession
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
|
||||
//http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
|
||||
const val STATE_RESUME_WINDOW = "resumeWindow"
|
||||
const val STATE_RESUME_POSITION = "resumePosition"
|
||||
|
@ -96,6 +102,8 @@ class PlayerFragment : Fragment() {
|
|||
private var isLoading = true
|
||||
private lateinit var exoPlayer: SimpleExoPlayer
|
||||
|
||||
private lateinit var settingsManager: SharedPreferences
|
||||
|
||||
private fun seekTime(time: Long) {
|
||||
exoPlayer.seekTo(maxOf(minOf(exoPlayer.currentPosition + time, exoPlayer.duration), 0))
|
||||
}
|
||||
|
@ -220,6 +228,38 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
|
||||
println(episodes)
|
||||
settingsManager = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
|
||||
val fastForwardTime = settingsManager.getInt("fast_forward_button_time", 10)
|
||||
exo_rew_text.text = fastForwardTime.toString()
|
||||
exo_ffwd_text.text = fastForwardTime.toString()
|
||||
exo_rew.setOnClickListener {
|
||||
val rotateLeft = AnimationUtils.loadAnimation(context, R.anim.rotate_left)
|
||||
exo_rew.startAnimation(rotateLeft)
|
||||
|
||||
val goLeft = AnimationUtils.loadAnimation(context, R.anim.go_left)
|
||||
goLeft.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
exo_rew_text.text = "$fastForwardTime"
|
||||
}
|
||||
})
|
||||
exo_rew_text.startAnimation(goLeft)
|
||||
exo_rew_text.text = "-$fastForwardTime"
|
||||
seekTime(fastForwardTime * -1000L)
|
||||
|
||||
}
|
||||
exo_ffwd.setOnClickListener {
|
||||
val rotateRight = AnimationUtils.loadAnimation(context, R.anim.rotate_right)
|
||||
exo_ffwd.startAnimation(rotateRight)
|
||||
seekTime(fastForwardTime * 1000L)
|
||||
}
|
||||
}
|
||||
|
||||
fun getCurrentUrl(): ExtractorLink {
|
||||
|
@ -249,7 +289,7 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
// releasePlayer()
|
||||
// releasePlayer()
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
}
|
||||
|
||||
|
@ -280,6 +320,7 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
private var currentWindow = 0
|
||||
private var playbackPosition: Long = 0
|
||||
|
||||
//http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
|
||||
private fun initPlayer() {
|
||||
println("INIT PLAYER")
|
||||
|
@ -292,7 +333,7 @@ class PlayerFragment : Fragment() {
|
|||
//MainActivity.popCurrentPage()
|
||||
}
|
||||
} else {
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
|
||||
try {
|
||||
activity?.runOnUiThread {
|
||||
val isOnline =
|
||||
|
@ -371,11 +412,11 @@ class PlayerFragment : Fragment() {
|
|||
|
||||
//https://stackoverflow.com/questions/47731779/detect-pause-resume-in-exoplayer
|
||||
exoPlayer.addListener(object : Player.Listener {
|
||||
// @SuppressLint("NewApi")
|
||||
// @SuppressLint("NewApi")
|
||||
override fun onPlayerStateChanged(playWhenReady: Boolean, playbackState: Int) {
|
||||
// updatePIPModeActions()
|
||||
// updatePIPModeActions()
|
||||
if (playWhenReady && playbackState == Player.STATE_READY) {
|
||||
// focusRequest?.let { activity?.requestAudioFocus(it) }
|
||||
// focusRequest?.let { activity?.requestAudioFocus(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
app/src/main/res/anim/go_left.xml
Normal file
11
app/src/main/res/anim/go_left.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
>
|
||||
<translate
|
||||
android:fromXDelta="0"
|
||||
android:toXDelta="-200"
|
||||
android:duration="200"
|
||||
>
|
||||
</translate>
|
||||
</set>
|
10
app/src/main/res/anim/go_right.xml
Normal file
10
app/src/main/res/anim/go_right.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
>
|
||||
<translate
|
||||
android:fromXDelta="0"
|
||||
android:toXDelta="100"
|
||||
>
|
||||
</translate>
|
||||
</set>
|
27
app/src/main/res/anim/rotate_left.xml
Normal file
27
app/src/main/res/anim/rotate_left.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
>
|
||||
<rotate android:fromDegrees="0"
|
||||
android:toDegrees="-90"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:duration="50"
|
||||
/>
|
||||
<rotate android:fromDegrees="0"
|
||||
android:toDegrees="90"
|
||||
android:startOffset="50"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:duration="50"
|
||||
/>
|
||||
<scale android:fromXScale="1.0" android:fromYScale="0.9"
|
||||
android:toXScale="1.0" android:toYScale="0.9"
|
||||
android:pivotX="50%" android:pivotY="50%"
|
||||
android:duration="50"/>
|
||||
<scale android:fromXScale="0.9" android:fromYScale="1"
|
||||
android:toXScale="0.9" android:toYScale="1"
|
||||
android:pivotX="50%" android:pivotY="50%"
|
||||
android:duration="50" android:startOffset="50"/>
|
||||
</set>
|
27
app/src/main/res/anim/rotate_right.xml
Normal file
27
app/src/main/res/anim/rotate_right.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
>
|
||||
<rotate android:fromDegrees="0"
|
||||
android:toDegrees="90"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:duration="50"
|
||||
/>
|
||||
<rotate android:fromDegrees="0"
|
||||
android:toDegrees="-90"
|
||||
android:startOffset="50"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:duration="50"
|
||||
/>
|
||||
<scale android:fromXScale="1.0" android:fromYScale="0.9"
|
||||
android:toXScale="1.0" android:toYScale="0.9"
|
||||
android:pivotX="50%" android:pivotY="50%"
|
||||
android:duration="50"/>
|
||||
<scale android:fromXScale="0.9" android:fromYScale="1"
|
||||
android:toXScale="0.9" android:toYScale="1"
|
||||
android:pivotX="50%" android:pivotY="50%"
|
||||
android:duration="50" android:startOffset="50"/>
|
||||
</set>
|
7
app/src/main/res/drawable/video_pause.xml
Normal file
7
app/src/main/res/drawable/video_pause.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/video_ripple">
|
||||
<item android:drawable="@drawable/netflix_pause" android:height="70dp" android:width="70dp" android:gravity="center">
|
||||
|
||||
</item>
|
||||
</layer-list>
|
7
app/src/main/res/drawable/video_play.xml
Normal file
7
app/src/main/res/drawable/video_play.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/video_ripple">
|
||||
<item android:drawable="@drawable/netflix_play" android:height="70dp" android:width="70dp" android:gravity="center">
|
||||
|
||||
</item>
|
||||
</layer-list>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/video_ripple">
|
||||
<item android:id="@android:id/mask">
|
||||
<item android:id="@android:id/mask" android:gravity="center">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/video_ripple"/>
|
||||
</shape>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/video_ripple">
|
||||
<item android:id="@android:id/mask" android:height="40dp" android:width="40dp" android:left="5dp" android:top="5dp">
|
||||
<item android:id="@android:id/mask" android:height="35dp" android:width="35dp" android:gravity="center">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/video_ripple"/>
|
||||
</shape>
|
||||
|
|
|
@ -193,8 +193,9 @@
|
|||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/centerMenu"
|
||||
|
@ -203,23 +204,26 @@
|
|||
<FrameLayout android:layout_width="wrap_content"
|
||||
android:layout_marginEnd="140dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content" tools:ignore="RtlSymmetry">
|
||||
<TextView
|
||||
android:id="@+id/exo_rew_text"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/player_skip_button_text"
|
||||
android:textSize="15sp"
|
||||
android:textSize="19sp"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:textFontWeight="900"
|
||||
android:gravity="center"
|
||||
android:layout_width="40dp"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp">
|
||||
</TextView>
|
||||
<ImageButton
|
||||
android:id="@id/exo_rew"
|
||||
android:layout_height="50dp"
|
||||
android:layout_width="50dp"
|
||||
android:padding="5dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="70dp"
|
||||
android:layout_gravity="center"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/video_tap_button_skip"
|
||||
android:src="@drawable/netflix_skip_back"
|
||||
android:scaleType="fitCenter"
|
||||
|
@ -234,21 +238,21 @@
|
|||
<ImageButton
|
||||
android:id="@id/exo_play"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_width="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/video_tap_button_always_white"
|
||||
android:foreground="@drawable/netflix_play"
|
||||
android:foreground="@drawable/video_play"
|
||||
android:clickable="true"
|
||||
android:focusable="true"/>
|
||||
<ImageButton
|
||||
android:id="@id/exo_pause"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_width="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/video_tap_button_always_white"
|
||||
android:foreground="@drawable/netflix_pause"
|
||||
android:foreground="@drawable/video_pause"
|
||||
android:clickable="true"
|
||||
android:focusable="true"/>
|
||||
|
||||
|
@ -261,9 +265,9 @@
|
|||
android:id="@+id/exo_ffwd_text"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/player_skip_button_text"
|
||||
android:textSize="15sp"
|
||||
android:textSize="19sp"
|
||||
android:layout_gravity="center"
|
||||
android:textFontWeight="900"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp">
|
||||
|
@ -271,18 +275,15 @@
|
|||
<ImageButton
|
||||
android:layout_gravity="center"
|
||||
android:id="@id/exo_ffwd"
|
||||
android:layout_height="50dp"
|
||||
android:layout_width="50dp"
|
||||
android:padding="5dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="70dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/video_tap_button_skip"
|
||||
android:src="@drawable/netflix_skip_forward"
|
||||
android:scaleType="fitCenter"
|
||||
android:tintMode="src_in"
|
||||
|
||||
/>
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
@ -324,7 +325,6 @@
|
|||
style="@style/ExoMediaButton.VR"
|
||||
android:tint="?attr/colorPrimaryDark"
|
||||
android:tintMode="src_in"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -354,17 +354,23 @@
|
|||
android:includeFontPadding="false"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp"
|
||||
android:gravity="end"
|
||||
android:minWidth="50dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"/>
|
||||
android:textStyle="normal"/>
|
||||
|
||||
<com.google.android.exoplayer2.ui.DefaultTimeBar
|
||||
android:id="@id/exo_progress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
app:played_color="?attr/colorPrimary"
|
||||
app:unplayed_color="@color/darkBar"/>
|
||||
app:scrubber_enabled_size="24dp"
|
||||
app:scrubber_dragged_size="26dp"
|
||||
app:scrubber_color="@color/videoColorPrimary"
|
||||
app:bar_height="2dp"
|
||||
app:played_color="@color/videoColorPrimary"
|
||||
app:unplayed_color="@color/videoProgress"/>
|
||||
|
||||
<TextView
|
||||
tools:text="23:20"
|
||||
|
@ -374,9 +380,10 @@
|
|||
android:includeFontPadding="false"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp"
|
||||
android:minWidth="50dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:textStyle="normal"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
@ -387,6 +394,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
|
@ -426,6 +435,8 @@
|
|||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
>
|
||||
|
@ -473,6 +484,9 @@
|
|||
android:paddingEnd="10dp"
|
||||
android:id="@+id/player_speed_text"
|
||||
android:layout_gravity="center"
|
||||
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@android:color/white"
|
||||
>
|
||||
</TextView>
|
||||
|
@ -517,6 +531,9 @@
|
|||
android:text="Source"
|
||||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:paddingEnd="10dp"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
|
@ -561,6 +578,9 @@
|
|||
android:text="Skip OP"
|
||||
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"
|
||||
|
@ -671,8 +691,6 @@
|
|||
android:progress="100"
|
||||
android:progressDrawable="@drawable/progress_drawable_vertical"
|
||||
>
|
||||
|
||||
|
||||
</ProgressBar>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
<color name="typeColor">#F54A3B</color>
|
||||
<color name="typeColorBg">#4DF54A3B</color>
|
||||
|
||||
<color name="video_ripple">#80FFFFFF</color>
|
||||
<color name="video_ripple">#73FFFFFF</color>
|
||||
<color name="black_overlay">#66000000</color>
|
||||
<color name="darkBarTransparent">#C0121212</color>
|
||||
<color name="darkBar">#121212</color>
|
||||
<color name="videoProgress">#66B5B5B5</color>
|
||||
<color name="videoColorPrimary">#617EFF</color>
|
||||
</resources>
|
Loading…
Reference in a new issue