diff options
| author | 2018-01-26 09:42:02 +0000 | |
|---|---|---|
| committer | 2018-01-26 09:42:02 +0000 | |
| commit | 6cb0712c53b340b0960800e878d980e66724bbbf (patch) | |
| tree | 316d6475ecd89e5cf5e1e1a26d8dc1505568714c | |
| parent | 1caef5b882111f1911fd3438fb11fbf5793a89a5 (diff) | |
| parent | 46377a9aaea75f5dfc3b9365142c6e65398e2afe (diff) | |
Merge "VideoView2: Add custom actions API"
| -rw-r--r-- | core/java/android/widget/VideoView2.java | 31 | ||||
| -rw-r--r-- | media/java/android/media/update/VideoView2Provider.java | 3 |
2 files changed, 34 insertions, 0 deletions
diff --git a/core/java/android/widget/VideoView2.java b/core/java/android/widget/VideoView2.java index 2ce724177462..e09382919e50 100644 --- a/core/java/android/widget/VideoView2.java +++ b/core/java/android/widget/VideoView2.java @@ -24,10 +24,12 @@ import android.media.AudioAttributes; import android.media.AudioManager; import android.media.MediaPlayerInterface; import android.media.session.MediaController; +import android.media.session.PlaybackState; import android.media.update.ApiLoader; import android.media.update.VideoView2Provider; import android.media.update.ViewProvider; import android.net.Uri; +import android.os.Bundle; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; @@ -321,6 +323,19 @@ public class VideoView2 extends FrameLayout { } /** + * Sets custom actions which will be shown as custom buttons in {@link MediaControlView2}. + * + * @param actionList A list of {@link PlaybackState.CustomAction}. The return value of + * {@link PlaybackState.CustomAction#getIcon()} will be used to draw buttons + * in {@link MediaControlView2}. + * @param listener A listener to be called when a custom button is clicked. + */ + public void setCustomActions(List<PlaybackState.CustomAction> actionList, + OnCustomActionListener listener) { + mProvider.setCustomActions_impl(actionList, listener); + } + + /** * Registers a callback to be invoked when the media file is loaded and ready to go. * * @param l the callback that will be run. @@ -455,6 +470,22 @@ public class VideoView2 extends FrameLayout { void onFullScreenChanged(View view, boolean fullScreen); } + /** + * Interface definition of a callback to be invoked to inform that a custom action is performed. + * + * TODO: When MediaSession2 is ready, modify the method to match the signature. + */ + public interface OnCustomActionListener { + /** + * Called to indicate that a custom action is performed. + * + * @param action The action that was originally sent in the + * {@link PlaybackState.CustomAction}. + * @param extras Optional extras. + */ + void onCustomAction(String action, Bundle extras); + } + @Override protected void onAttachedToWindow() { mProvider.onAttachedToWindow_impl(); diff --git a/media/java/android/media/update/VideoView2Provider.java b/media/java/android/media/update/VideoView2Provider.java index d4b4375164b8..322a4f6304d8 100644 --- a/media/java/android/media/update/VideoView2Provider.java +++ b/media/java/android/media/update/VideoView2Provider.java @@ -19,6 +19,7 @@ package android.media.update; import android.media.AudioAttributes; import android.media.MediaPlayerInterface; import android.media.session.MediaController; +import android.media.session.PlaybackState; import android.net.Uri; import android.widget.MediaControlView2; import android.widget.VideoView2; @@ -57,6 +58,8 @@ public interface VideoView2Provider extends ViewProvider { void setVideoUri_impl(Uri uri, Map<String, String> headers); void setViewType_impl(int viewType); int getViewType_impl(); + void setCustomActions_impl(List<PlaybackState.CustomAction> actionList, + VideoView2.OnCustomActionListener listener); void setOnPreparedListener_impl(VideoView2.OnPreparedListener l); void setOnCompletionListener_impl(VideoView2.OnCompletionListener l); void setOnErrorListener_impl(VideoView2.OnErrorListener l); |