mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #1764 from Bnyro/master
reset btns for speed and pitch
This commit is contained in:
commit
4b82a6ffd8
@ -31,18 +31,28 @@ class PlaybackSpeedSheet(
|
|||||||
binding.pitch.value = player.playbackParameters.pitch
|
binding.pitch.value = player.playbackParameters.pitch
|
||||||
|
|
||||||
binding.speed.addOnChangeListener { _, value, _ ->
|
binding.speed.addOnChangeListener { _, value, _ ->
|
||||||
onChange(value, binding.pitch.value.round(2))
|
onChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.pitch.addOnChangeListener { _, value, _ ->
|
binding.pitch.addOnChangeListener { _, value, _ ->
|
||||||
onChange(binding.speed.value.round(2), value)
|
onChange()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.resetSpeed.setOnClickListener {
|
||||||
|
binding.speed.value = 1f
|
||||||
|
onChange()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.resetPitch.setOnClickListener {
|
||||||
|
binding.pitch.value = 1f
|
||||||
|
onChange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onChange(speed: Float, pitch: Float) {
|
private fun onChange() {
|
||||||
player.playbackParameters = PlaybackParameters(
|
player.playbackParameters = PlaybackParameters(
|
||||||
speed,
|
binding.speed.value.round(2),
|
||||||
pitch
|
binding.pitch.value.round(2)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,28 +34,61 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/playback_speed" />
|
android:text="@string/playback_speed" />
|
||||||
|
|
||||||
<com.google.android.material.slider.Slider
|
<LinearLayout
|
||||||
android:id="@+id/speed"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:stepSize="0.1"
|
|
||||||
android:value="1.0"
|
<com.google.android.material.slider.Slider
|
||||||
android:valueFrom="0.2"
|
android:id="@+id/speed"
|
||||||
android:valueTo="4.0" />
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:stepSize="0.1"
|
||||||
|
android:value="1.0"
|
||||||
|
android:valueFrom="0.2"
|
||||||
|
android:valueTo="4.0" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/reset_speed"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_history" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/playback_pitch" />
|
android:text="@string/playback_pitch" />
|
||||||
|
|
||||||
<com.google.android.material.slider.Slider
|
<LinearLayout
|
||||||
android:id="@+id/pitch"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:stepSize="0.1"
|
android:orientation="horizontal">
|
||||||
android:value="1.0"
|
|
||||||
android:valueFrom="0.5"
|
<com.google.android.material.slider.Slider
|
||||||
android:valueTo="2.0" />
|
android:id="@+id/pitch"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:stepSize="0.1"
|
||||||
|
android:value="1.0"
|
||||||
|
android:valueFrom="0.5"
|
||||||
|
android:valueTo="2.0" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/reset_pitch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_history" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user