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

Commit 46377a9a authored by Hyundo Moon's avatar Hyundo Moon
Browse files

VideoView2: Add custom actions API

Test: Using VideoViewTest application
Change-Id: I941bf0f9605918b0e0f9e4684327eee9ffe24e11
parent ea27314e
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -24,10 +24,12 @@ import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaPlayerBase;
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;
@@ -315,6 +317,19 @@ public class VideoView2 extends FrameLayout {
        return mProvider.getViewType_impl();
    }

    /**
     * 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.
     *
@@ -449,6 +464,22 @@ public class VideoView2 extends FrameLayout {
        void onFullScreenChanged(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();
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.media.update;
import android.media.AudioAttributes;
import android.media.MediaPlayerBase;
import android.media.session.MediaController;
import android.media.session.PlaybackState;
import android.net.Uri;
import android.widget.MediaControlView2;
import android.widget.VideoView2;
@@ -58,6 +59,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);