Skip to content

Commit 9d09840

Browse files
tianyiftonihei
authored andcommitted
Add PlaybackParameters.withPitch() method
Issue: #2257 PiperOrigin-RevId: 742693410 (cherry picked from commit ce3754a)
1 parent 9483cbf commit 9d09840

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
@@ -7,6 +7,9 @@
77
### Unreleased changes
88

99
* Common Library:
10+
* Add `PlaybackParameters.withPitch(float)` method for easily copying a
11+
`PlaybackParameters` with a new `pitch` value
12+
([#2257](https://github.com/androidx/media/issues/2257)).
1013
* ExoPlayer:
1114
* Fix sending `CmcdData` in manifest requests for DASH, HLS, and
1215
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)