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

Commit 421e7ec3 authored by Jin Seok Park's avatar Jin Seok Park Committed by Android (Google) Code Review
Browse files

Merge "Put latest MediaControlView2/VideoView2 code"

parents 495ea5f8 efeb45ea
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.media.update.ViewProvider;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;

/**
 * A View that contains the controls for MediaPlayer2.
@@ -47,6 +48,19 @@ import android.view.MotionEvent;
 * @hide
 */
public class MediaControlView2 extends FrameLayout {
    // TODO: should overflow button be included?
    public static final int BUTTON_PLAY_PAUSE = 1;
    public static final int BUTTON_FFWD = 2;
    public static final int BUTTON_REW = 3;
    public static final int BUTTON_NEXT = 4;
    public static final int BUTTON_PREV = 5;
    public static final int BUTTON_SUBTITLE = 6;
    public static final int BUTTON_FULL_SCREEN = 7;
    public static final int BUTTON_OVERFLOW = 8;
    public static final int BUTTON_MUTE = 9;
    public static final int BUTTON_ASPECT_RATIO = 10;
    public static final int BUTTON_SETTINGS = 11;

    private final MediaControlView2Provider mProvider;

    public MediaControlView2(@NonNull Context context) {
@@ -172,10 +186,33 @@ public class MediaControlView2 extends FrameLayout {
        mProvider.hideSubtitle_impl();
    }

    /**
     * Set listeners for previous and next buttons to customize the behavior of clicking them.
     * The UI for these buttons are provided as default and will be automatically displayed when
     * this method is called.
     *
     * @param next Listener for clicking next button
     * @param prev Listener for clicking previous button
     */
    public void setPrevNextListeners(View.OnClickListener next, View.OnClickListener prev) {
        mProvider.setPrevNextListeners_impl(next, prev);
    }

    /**
     * Hides the specified button from view.
     *
     * @param button the constant integer assigned to individual buttons
     * @param visible whether the button should be visible or not
     */
    public void setButtonVisibility(int button, boolean visible) {
        mProvider.setButtonVisibility_impl(button, visible);
    }

    @Override
    protected void onAttachedToWindow() {
        mProvider.onAttachedToWindow_impl();
    }

    @Override
    protected void onDetachedFromWindow() {
        mProvider.onDetachedFromWindow_impl();
+24 −0
Original line number Diff line number Diff line
@@ -237,6 +237,13 @@ public class VideoView2 extends FrameLayout {
        mProvider.hideSubtitle_impl();
    }

    /**
     * Sets full screen mode.
     */
    public void setFullScreen(boolean fullScreen) {
        mProvider.setFullScreen_impl(fullScreen);
    }

    // TODO: This should be revised after integration with MediaPlayer2.
    /**
     * Sets playback speed.
@@ -416,6 +423,13 @@ public class VideoView2 extends FrameLayout {
        mProvider.setOnViewTypeChangedListener_impl(l);
    }

    /**
     * Registers a callback to be invoked when the fullscreen mode should be changed.
     */
    public void setFullScreenChangedListener(OnFullScreenChangedListener l) {
        mProvider.setFullScreenChangedListener_impl(l);
    }

    /**
     * Interface definition of a callback to be invoked when the viw type has been changed.
     */
@@ -484,6 +498,16 @@ public class VideoView2 extends FrameLayout {
        void onInfo(int what, int extra);
    }

    /**
     * Interface definition of a callback to be invoked to inform the fullscreen mode is changed.
     */
    public interface OnFullScreenChangedListener {
        /**
         * Called to indicate a fullscreen mode change.
         */
        void onFullScreenChanged(boolean fullScreen);
    }

    @Override
    protected void onAttachedToWindow() {
        mProvider.onAttachedToWindow_impl();
+2 −0
Original line number Diff line number Diff line
@@ -48,4 +48,6 @@ public interface MediaControlView2Provider extends ViewProvider {
    boolean canSeekForward_impl();
    void showSubtitle_impl();
    void hideSubtitle_impl();
    void setPrevNextListeners_impl(View.OnClickListener next, View.OnClickListener prev);
    void setButtonVisibility_impl(int button, boolean visible);
}
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public interface VideoView2Provider extends ViewProvider {
    int getAudioSessionId_impl();
    void showSubtitle_impl();
    void hideSubtitle_impl();
    void setFullScreen_impl(boolean fullScreen);
    void setSpeed_impl(float speed);
    float getSpeed_impl();
    void setAudioFocusRequest_impl(int focusGain);
@@ -68,4 +69,5 @@ public interface VideoView2Provider extends ViewProvider {
    void setOnErrorListener_impl(VideoView2.OnErrorListener l);
    void setOnInfoListener_impl(VideoView2.OnInfoListener l);
    void setOnViewTypeChangedListener_impl(VideoView2.OnViewTypeChangedListener l);
    void setFullScreenChangedListener_impl(VideoView2.OnFullScreenChangedListener l);
}