Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d8de690 authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Enhance Javadoc of playback speed related APIs

This CL also makes throw IllegalArgumentException when controller
tries to set the speed to zero.

Bug: 131873534
Test: atest CtsMediaTestCases:android.media.cts.MediaSessionTest;
      atest CtsMediaTestCases:android.media.cts.MediaControllerTest;
      atest CtsMediaTestCases:android.media.cts.MediaBrowserTest;
      atest CtsMediaTestCases:android.media.cts.MediaSessionManagerTest;
Change-Id: I78f775df369de48b1ebda66fdb6e251b6e0865c1
parent a9ac86f6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -891,11 +891,16 @@ public final class MediaController {
        }

        /**
         * Set the playback speed.
         * Sets the playback speed. A value of {@code 1.0f} is the default playback value,
         * and a negative value indicates reverse playback. {@code 0.0f} is not allowed.
         *
         * @param speed The playback speed
         * @throws IllegalArgumentException if the {@code speed} is equal to zero.
         */
        public void setPlaybackSpeed(float speed) {
            if (speed == 0.0f) {
                throw new IllegalArgumentException("speed must not be zero");
            }
            try {
                mSessionBinder.setPlaybackSpeed(mContext.getPackageName(), mCbStub, speed);
            } catch (RemoteException e) {
+3 −0
Original line number Diff line number Diff line
@@ -1084,6 +1084,9 @@ public final class MediaSession {
         * To update the new playback speed, create a new {@link PlaybackState} by using {@link
         * PlaybackState.Builder#setState(int, long, float)}, and set it with
         * {@link #setPlaybackState(PlaybackState)}.
         * <p>
         * A value of {@code 1.0f} is the default playback value, and a negative value indicates
         * reverse playback. The {@code speed} will not be equal to zero.
         *
         * @param speed the playback speed
         * @see #setPlaybackState(PlaybackState)