Commit 47d5dd91 by ibaker Committed by Oliver Woodman

Document ExoMediaDrm listener methods as optional

Also document FrameworkMediaDrm overrides as dependent on API level.

These two methods call through to equivalent methods on MediaDrm that
were added in 23:
https://developer.android.com/reference/android/media/MediaDrm#setOnExpirationUpdateListener(java.util.concurrent.Executor,%20android.media.MediaDrm.OnExpirationUpdateListener)

PiperOrigin-RevId: 303102370
parent b314da5f
...@@ -224,13 +224,40 @@ public interface ExoMediaDrm { ...@@ -224,13 +224,40 @@ public interface ExoMediaDrm {
} }
/** @see MediaDrm#setOnEventListener(MediaDrm.OnEventListener) */ /**
* Sets the listener for DRM events.
*
* <p>This is an optional method, and some implementations may only support it on certain Android
* API levels.
*
* @param listener The listener to receive events, or {@code null} to stop receiving events.
* @throws UnsupportedOperationException if the implementation doesn't support this method.
* @see MediaDrm#setOnEventListener(MediaDrm.OnEventListener)
*/
void setOnEventListener(@Nullable OnEventListener listener); void setOnEventListener(@Nullable OnEventListener listener);
/** @see MediaDrm#setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler) */ /**
* Sets the listener for key status change events.
*
* <p>This is an optional method, and some implementations may only support it on certain Android
* API levels.
*
* @param listener The listener to receive events, or {@code null} to stop receiving events.
* @throws UnsupportedOperationException if the implementation doesn't support this method.
* @see MediaDrm#setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler)
*/
void setOnKeyStatusChangeListener(@Nullable OnKeyStatusChangeListener listener); void setOnKeyStatusChangeListener(@Nullable OnKeyStatusChangeListener listener);
/** @see MediaDrm#setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler) */ /**
* Sets the listener for session expiration events.
*
* <p>This is an optional method, and some implementations may only support it on certain Android
* API levels.
*
* @param listener The listener to receive events, or {@code null} to stop receiving events.
* @throws UnsupportedOperationException if the implementation doesn't support this method.
* @see MediaDrm#setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler)
*/
void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener); void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener);
/** @see MediaDrm#openSession() */ /** @see MediaDrm#openSession() */
......
...@@ -114,7 +114,14 @@ public final class FrameworkMediaDrm implements ExoMediaDrm { ...@@ -114,7 +114,14 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
listener.onEvent(FrameworkMediaDrm.this, sessionId, event, extra, data)); listener.onEvent(FrameworkMediaDrm.this, sessionId, event, extra, data));
} }
/**
* {@inheritDoc}
*
* @param listener The listener to receive events, or {@code null} to stop receiving events.
* @throws UnsupportedOperationException on API levels lower than 23.
*/
@Override @Override
@RequiresApi(23)
public void setOnKeyStatusChangeListener( public void setOnKeyStatusChangeListener(
@Nullable ExoMediaDrm.OnKeyStatusChangeListener listener) { @Nullable ExoMediaDrm.OnKeyStatusChangeListener listener) {
if (Util.SDK_INT < 23) { if (Util.SDK_INT < 23) {
...@@ -135,7 +142,14 @@ public final class FrameworkMediaDrm implements ExoMediaDrm { ...@@ -135,7 +142,14 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
/* handler= */ null); /* handler= */ null);
} }
/**
* {@inheritDoc}
*
* @param listener The listener to receive events, or {@code null} to stop receiving events.
* @throws UnsupportedOperationException on API levels lower than 23.
*/
@Override @Override
@RequiresApi(23)
public void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener) { public void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener) {
if (Util.SDK_INT < 23) { if (Util.SDK_INT < 23) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment