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

Commit 58c83fa7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Unhide VideoView2 APIs"

parents dc66a1d8 b785faa1
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -54666,6 +54666,27 @@ package android.widget {
    method public void suspend();
  }
  public class VideoView2 extends android.view.ViewGroup {
    ctor public VideoView2(android.content.Context);
    ctor public VideoView2(android.content.Context, android.util.AttributeSet);
    ctor public VideoView2(android.content.Context, android.util.AttributeSet, int);
    ctor public VideoView2(android.content.Context, android.util.AttributeSet, int, int);
    method public android.widget.MediaControlView2 getMediaControlView2();
    method public android.media.SessionToken2 getMediaSessionToken();
    method public int getViewType();
    method public boolean isSubtitleEnabled();
    method public void setAudioAttributes(android.media.AudioAttributes);
    method public void setAudioFocusRequest(int);
    method public void setDataSource(android.media.DataSourceDesc);
    method public void setMediaControlView2(android.widget.MediaControlView2, long);
    method public void setMediaItem(android.media.MediaItem2);
    method public void setSpeed(float);
    method public void setSubtitleEnabled(boolean);
    method public void setViewType(int);
    field public static final int VIEW_TYPE_SURFACEVIEW = 1; // 0x1
    field public static final int VIEW_TYPE_TEXTUREVIEW = 2; // 0x2
  }
  public class ViewAnimator extends android.widget.FrameLayout {
    ctor public ViewAnimator(android.content.Context);
    ctor public ViewAnimator(android.content.Context, android.util.AttributeSet);
+49 −7
Original line number Diff line number Diff line
@@ -22,8 +22,12 @@ import android.annotation.Nullable;
import android.content.Context;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.DataSourceDesc;
import android.media.MediaItem2;
import android.media.MediaMetadata2;
import android.media.MediaPlayer2;
import android.media.MediaPlayerBase;
import android.media.SessionToken2;
import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.PlaybackState;
@@ -45,14 +49,14 @@ import java.util.concurrent.Executor;

// 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.
 * Displays a video file.  VideoView2 class is a View class which is wrapping {@link MediaPlayer2}
 * so that developers can easily implement a video rendering application.
 *
 * <p>
 * <em> Data sources that VideoView2 supports : </em>
 * VideoView2 can play video files and audio-only files as
 * well. It can load from various sources such as resources or content providers. The supported
 * media file formats are the same as MediaPlayer2.
 * media file formats are the same as {@link MediaPlayer2}.
 *
 * <p>
 * <em> View type can be selected : </em>
@@ -101,8 +105,6 @@ import java.util.concurrent.Executor;
 * does not restore the current play state, play position, selected tracks. Applications should save
 * and restore these on their own in {@link android.app.Activity#onSaveInstanceState} and
 * {@link android.app.Activity#onRestoreInstanceState}.
 *
 * @hide
 */
public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
    /** @hide */
@@ -199,11 +201,23 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
     * before calling this method.
     *
     * @throws IllegalStateException if interal MediaSession is not created yet.
     * @hide  TODO: remove
     */
    public MediaController getMediaController() {
        return mProvider.getMediaController_impl();
    }

    /**
     * Returns {@link android.media.SessionToken2} so that developers create their own
     * {@link android.media.MediaController2} instance. This method should be called when VideoView2
     * is attached to window, or it throws IllegalStateException.
     *
     * @throws IllegalStateException if interal MediaSession is not created yet.
     */
    public SessionToken2 getMediaSessionToken() {
        return mProvider.getMediaSessionToken_impl();
    }

    /**
     * Shows or hides closed caption or subtitles if there is any.
     * The first subtitle track will be chosen if there multiple subtitle tracks exist.
@@ -265,6 +279,7 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
        mProvider.setAudioAttributes_impl(attributes);
    }

    // TODO: unhide this method when MediaPlayerInterface became unhidden.
    /**
     * Sets a remote player for handling playback of the selected route from MediaControlView2.
     * If this is not called, MediaCotrolView2 will not show the route button.
@@ -302,6 +317,8 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
     * Sets video path.
     *
     * @param path the path of the video.
     *
     * @hide TODO remove
     */
    public void setVideoPath(String path) {
        mProvider.setVideoPath_impl(path);
@@ -311,6 +328,8 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
     * Sets video URI.
     *
     * @param uri the URI of the video.
     *
     * @hide TODO remove
     */
    public void setVideoUri(Uri uri) {
        mProvider.setVideoUri_impl(uri);
@@ -325,11 +344,32 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
     *                changed with key/value pairs through the headers parameter with
     *                "android-allow-cross-domain-redirect" as the key and "0" or "1" as the value
     *                to disallow or allow cross domain redirection.
     *
     * @hide TODO remove
     */
    public void setVideoUri(Uri uri, Map<String, String> headers) {
        mProvider.setVideoUri_impl(uri, headers);
    }

    /**
     * Sets {@link MediaItem2} object to render using VideoView2. Alternative way to set media
     * object to VideoView2 is {@link #setDataSource}.
     * @param mediaItem the MediaItem2 to play
     * @see #setDataSource
     */
    public void setMediaItem(@NonNull MediaItem2 mediaItem) {
        mProvider.setMediaItem_impl(mediaItem);
    }

    /**
     * Sets {@link DataSourceDesc} object to render using VideoView2.
     * @param dataSource the {@link DataSourceDesc} object to play.
     * @see #setMediaItem
     */
    public void setDataSource(@NonNull DataSourceDesc dataSource) {
        mProvider.setDataSource_impl(dataSource);
    }

    /**
     * Selects which view will be used to render video between SurfacView and TextureView.
     *
@@ -361,6 +401,7 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
     *                   in {@link MediaControlView2}.
     * @param executor executor to run callbacks on.
     * @param listener A listener to be called when a custom button is clicked.
     * @hide  TODO remove
     */
    public void setCustomActions(List<PlaybackState.CustomAction> actionList,
            Executor executor, OnCustomActionListener listener) {
@@ -371,7 +412,6 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
     * Registers a callback to be invoked when a view type change is done.
     * {@see #setViewType(int)}
     * @param l The callback that will be run
     *
     * @hide
     */
    @VisibleForTesting
@@ -382,6 +422,7 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
    /**
     * Registers a callback to be invoked when the fullscreen mode should be changed.
     * @param l The callback that will be run
     * @hide  TODO remove
     */
    public void setFullScreenRequestListener(OnFullScreenRequestListener l) {
        mProvider.setFullScreenRequestListener_impl(l);
@@ -410,6 +451,7 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
    /**
     * Interface definition of a callback to be invoked to inform the fullscreen mode is changed.
     * Application should handle the fullscreen mode accordingly.
     * @hide  TODO remove
     */
    public interface OnFullScreenRequestListener {
        /**
@@ -420,8 +462,8 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {

    /**
     * Interface definition of a callback to be invoked to inform that a custom action is performed.
     * @hide  TODO remove
     */
    // TODO: When MediaSession2 is ready, modify the method to match the signature.
    public interface OnCustomActionListener {
        /**
         * Called to indicate that a custom action is performed.
+28 −0
Original line number Diff line number Diff line
@@ -18,8 +18,11 @@ package android.media.update;

import android.annotation.SystemApi;
import android.media.AudioAttributes;
import android.media.DataSourceDesc;
import android.media.MediaItem2;
import android.media.MediaMetadata2;
import android.media.MediaPlayerBase;
import android.media.SessionToken2;
import android.media.session.MediaController;
import android.media.session.PlaybackState;
import android.media.session.MediaSession;
@@ -53,7 +56,11 @@ public interface VideoView2Provider extends ViewGroupProvider {

    void setMediaControlView2_impl(MediaControlView2 mediaControlView, long intervalMs);
    void setMediaMetadata_impl(MediaMetadata2 metadata);
    /**
     * @hide TODO: remove
     */
    MediaController getMediaController_impl();
    SessionToken2 getMediaSessionToken_impl();
    MediaControlView2 getMediaControlView2_impl();
    MediaMetadata2 getMediaMetadata_impl();
    void setSubtitleEnabled_impl(boolean enable);
@@ -66,13 +73,31 @@ public interface VideoView2Provider extends ViewGroupProvider {
     * @hide
     */
    void setRouteAttributes_impl(List<String> routeCategories, MediaPlayerBase player);
    /**
     * @hide
     */
    // TODO: remove setRouteAttributes_impl with MediaSession.Callback once MediaSession2 is ready.
    void setRouteAttributes_impl(List<String> routeCategories, MediaSession.Callback sessionPlayer);

    /**
     * @hide TODO: remove
     */
    void setVideoPath_impl(String path);
    /**
     * @hide TODO: remove
     */
    void setVideoUri_impl(Uri uri);
    /**
     * @hide TODO: remove
     */
    void setVideoUri_impl(Uri uri, Map<String, String> headers);
    void setMediaItem_impl(MediaItem2 mediaItem);
    void setDataSource_impl(DataSourceDesc dsd);
    void setViewType_impl(int viewType);
    int getViewType_impl();
    /**
     * @hide TODO: remove
     */
    void setCustomActions_impl(List<PlaybackState.CustomAction> actionList,
            Executor executor, VideoView2.OnCustomActionListener listener);
    /**
@@ -80,5 +105,8 @@ public interface VideoView2Provider extends ViewGroupProvider {
     */
    @VisibleForTesting
    void setOnViewTypeChangedListener_impl(VideoView2.OnViewTypeChangedListener l);
    /**
     * @hide TODO: remove
     */
    void setFullScreenRequestListener_impl(VideoView2.OnFullScreenRequestListener l);
}