Home | History | Annotate | Download | only in impl_with_mp1
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package androidx.media.widget;
     18 
     19 import android.media.MediaPlayer;
     20 import android.view.View;
     21 
     22 import androidx.annotation.NonNull;
     23 
     24 interface VideoViewInterfaceWithMp1 {
     25     /**
     26      * Assigns the view's surface to the given MediaPlayer instance.
     27      *
     28      * @param mp MediaPlayer
     29      * @return true if the surface is successfully assigned, false if not. It will fail to assign
     30      *         if any of MediaPlayer or surface is unavailable.
     31      */
     32     boolean assignSurfaceToMediaPlayer(MediaPlayer mp);
     33     void setSurfaceListener(SurfaceListener l);
     34     int getViewType();
     35     void setMediaPlayer(MediaPlayer mp);
     36 
     37     /**
     38      * Takes over oldView. It means that the MediaPlayer will start rendering on this view.
     39      * The visibility of oldView will be set as {@link View.GONE}. If the view doesn't have a
     40      * MediaPlayer instance or its surface is not available, the actual execution is deferred until
     41      * a MediaPlayer instance is set by {@link #setMediaPlayer} or its surface becomes available.
     42      * {@link SurfaceListener.onSurfaceTakeOverDone} will be called when the actual execution is
     43      * done.
     44      *
     45      * @param oldView The view that MediaPlayer is currently rendering on.
     46      */
     47     void takeOver(@NonNull VideoViewInterfaceWithMp1 oldView);
     48 
     49     /**
     50      * Indicates if the view's surface is available.
     51      *
     52      * @return true if the surface is available.
     53      */
     54     boolean hasAvailableSurface();
     55 
     56     /**
     57      * An instance of VideoViewInterface calls these surface notification methods accordingly if
     58      * a listener has been registered via {@link #setSurfaceListener(SurfaceListener)}.
     59      */
     60     interface SurfaceListener {
     61         void onSurfaceCreated(View view, int width, int height);
     62         void onSurfaceDestroyed(View view);
     63         void onSurfaceChanged(View view, int width, int height);
     64         void onSurfaceTakeOverDone(VideoViewInterfaceWithMp1 view);
     65     }
     66 }
     67