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

Commit 620b7f32 authored by Insun Kang's avatar Insun Kang
Browse files

VideoView2: Adds Executor paramter to setFooListener methods

- Added Executor parameter to setFooListeners
- Removed setFullScreen()
- Renamed OnFullScreenChangedListener --> OnFullScreenRequestListener

Test: build
Change-Id: I1822876ecf55566182281a76ea7919d7c0112146
parent 8e2af197
Loading
Loading
Loading
Loading
+28 −28
Original line number Diff line number Diff line
@@ -38,10 +38,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;

// TODO: Use @link tag to refer MediaPlayer2 in docs once MediaPlayer2.java is submitted. Same to
// MediaSession2.
// TODO: change the reference from MediaPlayer to MediaPlayer2.
// TODO: Replace MediaSession wtih MediaSession2 once MediaSession2 is submitted.
/**
 * Displays a video file.  VideoView2 class is a View class which is wrapping MediaPlayer2 so that
 * developers can easily implement a video rendering application.
@@ -202,13 +201,6 @@ public class VideoView2 extends FrameLayout {
        mProvider.hideSubtitle_impl();
    }

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

    /**
     * Sets playback speed.
     *
@@ -327,30 +319,33 @@ public class VideoView2 extends FrameLayout {
     * @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 executor executor to run callbacks on.
     * @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);
            Executor executor, OnCustomActionListener listener) {
        mProvider.setCustomActions_impl(actionList, executor, listener);
    }

    /**
     * Registers a callback to be invoked when the media file is loaded and ready to go.
     *
     * @param executor executor to run callbacks on.
     * @param l the callback that will be run.
     */
    public void setOnPreparedListener(OnPreparedListener l) {
        mProvider.setOnPreparedListener_impl(l);
    public void setOnPreparedListener(Executor executor, OnPreparedListener l) {
        mProvider.setOnPreparedListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when the end of a media file has been reached during
     * playback.
     *
     * @param executor executor to run callbacks on.
     * @param l the callback that will be run.
     */
    public void setOnCompletionListener(OnCompletionListener l) {
        mProvider.setOnCompletionListener_impl(l);
    public void setOnCompletionListener(Executor executor, OnCompletionListener l) {
        mProvider.setOnCompletionListener_impl(executor, l);
    }

    /**
@@ -358,36 +353,41 @@ public class VideoView2 extends FrameLayout {
     * listener is specified, or if the listener returned false, VideoView2 will inform the user of
     * any errors.
     *
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setOnErrorListener(OnErrorListener l) {
        mProvider.setOnErrorListener_impl(l);
    public void setOnErrorListener(Executor executor, OnErrorListener l) {
        mProvider.setOnErrorListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when an informational event occurs during playback or
     * setup.
     *
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setOnInfoListener(OnInfoListener l) {
        mProvider.setOnInfoListener_impl(l);
    public void setOnInfoListener(Executor executor, OnInfoListener l) {
        mProvider.setOnInfoListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when a view type change is done.
     * {@see #setViewType(int)}
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setOnViewTypeChangedListener(OnViewTypeChangedListener l) {
        mProvider.setOnViewTypeChangedListener_impl(l);
    public void setOnViewTypeChangedListener(Executor executor, OnViewTypeChangedListener l) {
        mProvider.setOnViewTypeChangedListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when the fullscreen mode should be changed.
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setFullScreenChangedListener(OnFullScreenChangedListener l) {
        mProvider.setFullScreenChangedListener_impl(l);
    public void setFullScreenRequestListener(Executor executor, OnFullScreenRequestListener l) {
        mProvider.setFullScreenRequestListener_impl(executor, l);
    }

    /**
@@ -461,19 +461,19 @@ public class VideoView2 extends FrameLayout {

    /**
     * Interface definition of a callback to be invoked to inform the fullscreen mode is changed.
     * Application should handle the fullscreen mode accordingly.
     */
    public interface OnFullScreenChangedListener {
    public interface OnFullScreenRequestListener {
        /**
         * Called to indicate a fullscreen mode change.
         */
        void onFullScreenChanged(View view, boolean fullScreen);
        void onFullScreenRequest(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.
     */
    // TODO: When MediaSession2 is ready, modify the method to match the signature.
    public interface OnCustomActionListener {
        /**
         * Called to indicate that a custom action is performed.
+10 −8
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.widget.VideoView2;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;

/**
 * Interface for connecting the public API to an updatable implementation.
@@ -47,7 +48,6 @@ public interface VideoView2Provider extends ViewProvider {
    MediaControlView2 getMediaControlView2_impl();
    void showSubtitle_impl();
    void hideSubtitle_impl();
    void setFullScreen_impl(boolean fullScreen);
    // TODO: remove setSpeed_impl once MediaController2 is ready.
    void setSpeed_impl(float speed);
    void setAudioFocusRequest_impl(int focusGain);
@@ -59,11 +59,13 @@ public interface VideoView2Provider extends ViewProvider {
    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);
    void setOnInfoListener_impl(VideoView2.OnInfoListener l);
    void setOnViewTypeChangedListener_impl(VideoView2.OnViewTypeChangedListener l);
    void setFullScreenChangedListener_impl(VideoView2.OnFullScreenChangedListener l);
            Executor executor, VideoView2.OnCustomActionListener listener);
    void setOnPreparedListener_impl(Executor executor, VideoView2.OnPreparedListener l);
    void setOnCompletionListener_impl(Executor executor, VideoView2.OnCompletionListener l);
    void setOnErrorListener_impl(Executor executor, VideoView2.OnErrorListener l);
    void setOnInfoListener_impl(Executor executor, VideoView2.OnInfoListener l);
    void setOnViewTypeChangedListener_impl(
            Executor executor, VideoView2.OnViewTypeChangedListener l);
    void setFullScreenRequestListener_impl(
            Executor executor, VideoView2.OnFullScreenRequestListener l);
}