Merge pull request #1764 from Bnyro/master

reset btns for speed and pitch
This commit is contained in:
Bnyro 2022-11-05 17:27:51 +01:00 committed by GitHub
commit 4b82a6ffd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 18 deletions

View File

@ -31,18 +31,28 @@ class PlaybackSpeedSheet(
binding.pitch.value = player.playbackParameters.pitch
binding.speed.addOnChangeListener { _, value, _ ->
onChange(value, binding.pitch.value.round(2))
onChange()
}
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(
speed,
pitch
binding.speed.value.round(2),
binding.pitch.value.round(2)
)
}

View File

@ -34,28 +34,61 @@
android:layout_height="wrap_content"
android:text="@string/playback_speed" />
<com.google.android.material.slider.Slider
android:id="@+id/speed"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stepSize="0.1"
android:value="1.0"
android:valueFrom="0.2"
android:valueTo="4.0" />
android:layout_height="wrap_content">
<com.google.android.material.slider.Slider
android:id="@+id/speed"
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
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/playback_pitch" />
<com.google.android.material.slider.Slider
android:id="@+id/pitch"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stepSize="0.1"
android:value="1.0"
android:valueFrom="0.5"
android:valueTo="2.0" />
android:orientation="horizontal">
<com.google.android.material.slider.Slider
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>