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.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)
) )
} }

View File

@ -34,29 +34,62 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/playback_speed" /> android:text="@string/playback_speed" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.slider.Slider <com.google.android.material.slider.Slider
android:id="@+id/speed" android:id="@+id/speed"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:stepSize="0.1" android:stepSize="0.1"
android:value="1.0" android:value="1.0"
android:valueFrom="0.2" android:valueFrom="0.2"
android:valueTo="4.0" /> 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: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:stepSize="0.1"
android:value="1.0" android:value="1.0"
android:valueFrom="0.5" android:valueFrom="0.5"
android:valueTo="2.0" /> 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>
</LinearLayout> </LinearLayout>