11ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang/* 21ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * Copyright 2018 The Android Open Source Project 31ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * 41ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * Licensed under the Apache License, Version 2.0 (the "License"); 51ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * you may not use this file except in compliance with the License. 61ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * You may obtain a copy of the License at 71ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * 81ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * http://www.apache.org/licenses/LICENSE-2.0 91ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * 101ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * Unless required by applicable law or agreed to in writing, software 111ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * distributed under the License is distributed on an "AS IS" BASIS, 121ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * See the License for the specific language governing permissions and 141ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * limitations under the License. 151ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang */ 161ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 171ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kangpackage androidx.media.widget; 181ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 191ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kangimport android.view.View; 201ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 211ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kangimport androidx.annotation.NonNull; 221ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kangimport androidx.media.MediaPlayer2; 231ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 241ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kanginterface VideoViewInterface { 251ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang /** 261ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * Assigns the view's surface to the given MediaPlayer instance. 271ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * 281ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * @param mp MediaPlayer 291ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * @return true if the surface is successfully assigned, false if not. It will fail to assign 301ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * if any of MediaPlayer or surface is unavailable. 311ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang */ 321ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang boolean assignSurfaceToMediaPlayer(MediaPlayer2 mp); 331ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void setSurfaceListener(SurfaceListener l); 341ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang int getViewType(); 351ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void setMediaPlayer(MediaPlayer2 mp); 361ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 371ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang /** 381ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * Takes over oldView. It means that the MediaPlayer will start rendering on this view. 391ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * The visibility of oldView will be set as {@link View.GONE}. If the view doesn't have a 401ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * MediaPlayer instance or its surface is not available, the actual execution is deferred until 411ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * a MediaPlayer instance is set by {@link #setMediaPlayer} or its surface becomes available. 421ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * {@link SurfaceListener.onSurfaceTakeOverDone} will be called when the actual execution is 431ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * done. 441ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * 451ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * @param oldView The view that MediaPlayer is currently rendering on. 461ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang */ 471ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void takeOver(@NonNull VideoViewInterface oldView); 481ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 491ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang /** 501ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * Indicates if the view's surface is available. 511ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * 521ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * @return true if the surface is available. 531ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang */ 541ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang boolean hasAvailableSurface(); 551ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang 561ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang /** 571ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * An instance of VideoViewInterface calls these surface notification methods accordingly if 581ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang * a listener has been registered via {@link #setSurfaceListener(SurfaceListener)}. 591ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang */ 601ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang interface SurfaceListener { 611ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void onSurfaceCreated(View view, int width, int height); 621ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void onSurfaceDestroyed(View view); 631ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void onSurfaceChanged(View view, int width, int height); 641ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang void onSurfaceTakeOverDone(VideoViewInterface view); 651ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang } 661ed376b73eeaea2ba6211cde50575bf9734ff705Insun Kang} 67