mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-04 23:30:52 +00:00
Added next and previous buttons to cast controls.
This commit is contained in:
parent
14d579eb1b
commit
52d833d726
3 changed files with 58 additions and 1 deletions
|
@ -512,6 +512,8 @@ class VideoDetailView : ConstraintLayout {
|
||||||
_player.onDatasourceError.subscribe(::onDataSourceError);
|
_player.onDatasourceError.subscribe(::onDataSourceError);
|
||||||
_player.onNext.subscribe { nextVideo(true, true, true) };
|
_player.onNext.subscribe { nextVideo(true, true, true) };
|
||||||
_player.onPrevious.subscribe { prevVideo(true) };
|
_player.onPrevious.subscribe { prevVideo(true) };
|
||||||
|
_cast.onPrevious.subscribe { prevVideo(true) };
|
||||||
|
_cast.onNext.subscribe { nextVideo(true, true, true) };
|
||||||
|
|
||||||
_minimize_controls_play.setOnClickListener { handlePlay(); };
|
_minimize_controls_play.setOnClickListener { handlePlay(); };
|
||||||
_minimize_controls_pause.setOnClickListener { handlePause(); };
|
_minimize_controls_pause.setOnClickListener { handlePause(); };
|
||||||
|
|
|
@ -38,6 +38,8 @@ class CastView : ConstraintLayout {
|
||||||
private val _buttonSettings: ImageButton;
|
private val _buttonSettings: ImageButton;
|
||||||
private val _buttonLoop: ImageButton;
|
private val _buttonLoop: ImageButton;
|
||||||
private val _buttonPlay: ImageButton;
|
private val _buttonPlay: ImageButton;
|
||||||
|
private val _buttonPrevious: ImageButton;
|
||||||
|
private val _buttonNext: ImageButton;
|
||||||
private val _buttonPause: ImageButton;
|
private val _buttonPause: ImageButton;
|
||||||
private val _buttonCast: CastButton;
|
private val _buttonCast: CastButton;
|
||||||
private val _textPosition: TextView;
|
private val _textPosition: TextView;
|
||||||
|
@ -52,6 +54,8 @@ class CastView : ConstraintLayout {
|
||||||
|
|
||||||
val onMinimizeClick = Event0();
|
val onMinimizeClick = Event0();
|
||||||
val onSettingsClick = Event0();
|
val onSettingsClick = Event0();
|
||||||
|
val onPrevious = Event0();
|
||||||
|
val onNext = Event0();
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||||
|
@ -62,6 +66,8 @@ class CastView : ConstraintLayout {
|
||||||
_buttonSettings = findViewById(R.id.button_settings);
|
_buttonSettings = findViewById(R.id.button_settings);
|
||||||
_buttonLoop = findViewById(R.id.button_loop);
|
_buttonLoop = findViewById(R.id.button_loop);
|
||||||
_buttonPlay = findViewById(R.id.button_play);
|
_buttonPlay = findViewById(R.id.button_play);
|
||||||
|
_buttonPrevious = findViewById(R.id.button_previous);
|
||||||
|
_buttonNext = findViewById(R.id.button_next);
|
||||||
_buttonPause = findViewById(R.id.button_pause);
|
_buttonPause = findViewById(R.id.button_pause);
|
||||||
_buttonCast = findViewById(R.id.button_cast);
|
_buttonCast = findViewById(R.id.button_cast);
|
||||||
_textPosition = findViewById(R.id.text_position);
|
_textPosition = findViewById(R.id.text_position);
|
||||||
|
@ -105,6 +111,28 @@ class CastView : ConstraintLayout {
|
||||||
if (!isInEditMode) {
|
if (!isInEditMode) {
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatePlayer.instance.onQueueChanged.subscribe(this) {
|
||||||
|
CoroutineScope(Dispatchers.Main).launch(Dispatchers.Main) {
|
||||||
|
setLoopVisible(!StatePlayer.instance.hasQueue)
|
||||||
|
updateNextPrevious();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StatePlayer.instance.onVideoChanging.subscribe(this) {
|
||||||
|
CoroutineScope(Dispatchers.Main).launch(Dispatchers.Main) {
|
||||||
|
updateNextPrevious();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_buttonPrevious.setOnClickListener { onPrevious.emit() };
|
||||||
|
_buttonNext.setOnClickListener { onNext.emit() };
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateNextPrevious() {
|
||||||
|
val vidPrev = StatePlayer.instance.getPrevQueueItem(true);
|
||||||
|
val vidNext = StatePlayer.instance.getNextQueueItem(true);
|
||||||
|
_buttonNext.visibility = if (vidNext != null) View.VISIBLE else View.GONE
|
||||||
|
_buttonPrevious.visibility = if (vidPrev != null) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopTimeJob() {
|
fun stopTimeJob() {
|
||||||
|
|
|
@ -73,6 +73,19 @@
|
||||||
app:srcCompat="@drawable/ic_settings" />
|
app:srcCompat="@drawable/ic_settings" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@id/button_previous"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:clickable="true"
|
||||||
|
android:layout_marginRight="40dp"
|
||||||
|
android:padding="5dp"
|
||||||
|
app:srcCompat="@drawable/ic_skip_previous"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintRight_toLeftOf="@id/button_play"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/button_play"
|
android:id="@+id/button_play"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
|
@ -85,6 +98,20 @@
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
app:srcCompat="@drawable/ic_play_white_nopad" />
|
app:srcCompat="@drawable/ic_play_white_nopad" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@id/button_next"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:layout_marginLeft="40dp"
|
||||||
|
app:srcCompat="@drawable/ic_skip_next"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintLeft_toRightOf="@id/button_play"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/button_pause"
|
android:id="@+id/button_pause"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue