Skip to content

Commit ce3754a

Browse files
tianyifcopybara-github
authored andcommitted
Add PlaybackParameters.withPitch() method
Issue: #2257 PiperOrigin-RevId: 742693410
1 parent 209ecce commit ce3754a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### Unreleased changes
44

55
* Common Library:
6+
* Add `PlaybackParameters.withPitch(float)` method for easily copying a
7+
`PlaybackParameters` with a new `pitch` value
8+
([#2257](https://github.com/androidx/media/issues/2257)).
69
* ExoPlayer:
710
* Fix sending `CmcdData` in manifest requests for DASH, HLS, and
811
SmoothStreaming ([#2253](https://github.com/androidx/media/pull/2253)).

libraries/common/src/main/java/androidx/media3/common/PlaybackParameters.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ public PlaybackParameters withSpeed(@FloatRange(from = 0, fromInclusive = false)
8888
return new PlaybackParameters(speed, pitch);
8989
}
9090

91+
/**
92+
* Returns a copy with the given pitch.
93+
*
94+
* @param pitch The new pitch. Must be greater than zero.
95+
* @return The copied playback parameters.
96+
*/
97+
@UnstableApi
98+
@CheckResult
99+
public PlaybackParameters withPitch(@FloatRange(from = 0, fromInclusive = false) float pitch) {
100+
return new PlaybackParameters(speed, pitch);
101+
}
102+
91103
@Override
92104
public boolean equals(@Nullable Object obj) {
93105
if (this == obj) {

0 commit comments

Comments
 (0)