VideoView2.java revision b785faa1d71d64bba56e34dce93c7e8937845afc
1e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim/* 2e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * Copyright 2018 The Android Open Source Project 3e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * 4e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * Licensed under the Apache License, Version 2.0 (the "License"); 5e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * you may not use this file except in compliance with the License. 6e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * You may obtain a copy of the License at 7e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * 8e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * http://www.apache.org/licenses/LICENSE-2.0 9e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * 10e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * Unless required by applicable law or agreed to in writing, software 11e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * distributed under the License is distributed on an "AS IS" BASIS, 12e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * See the License for the specific language governing permissions and 14e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim * limitations under the License. 15e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 16e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 17e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limpackage android.widget; 18e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 19e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.annotation.IntDef; 20e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.annotation.NonNull; 21e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.annotation.Nullable; 22e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.content.Context; 23e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.media.AudioAttributes; 24de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kangimport android.media.AudioManager; 25b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kangimport android.media.DataSourceDesc; 26b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kangimport android.media.MediaItem2; 27b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Parkimport android.media.MediaMetadata2; 28b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kangimport android.media.MediaPlayer2; 296cc1a5de46ec18172d75ac589dbe8b306d0fb8d2Jaewan Kimimport android.media.MediaPlayerBase; 30b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kangimport android.media.SessionToken2; 3182af545ca64bff030697a0369e0301c03e8123ecSungsoo Limimport android.media.session.MediaController; 32d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Limimport android.media.session.MediaSession; 3346377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moonimport android.media.session.PlaybackState; 34e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.media.update.ApiLoader; 35e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.media.update.VideoView2Provider; 36f38d8fb9344954ed28ccaaee8e29dcd4d65f1fe0Christofer Ã…kerstenimport android.media.update.ViewGroupHelper; 37e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.net.Uri; 3846377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moonimport android.os.Bundle; 39e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport android.util.AttributeSet; 40df0728c15af0f6cc101883af097ffe680279448aInsun Kangimport android.view.View; 41e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 42a35d1b194696ff73970b640446b2391711ea6030Insun Kangimport com.android.internal.annotations.VisibleForTesting; 43a35d1b194696ff73970b640446b2391711ea6030Insun Kang 44e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport java.lang.annotation.Retention; 45e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport java.lang.annotation.RetentionPolicy; 46af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Limimport java.util.List; 47e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Limimport java.util.Map; 48620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kangimport java.util.concurrent.Executor; 49e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 50620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang// TODO: Replace MediaSession wtih MediaSession2 once MediaSession2 is submitted. 51e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim/** 52b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * Displays a video file. VideoView2 class is a View class which is wrapping {@link MediaPlayer2} 53b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * so that developers can easily implement a video rendering application. 54eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 55eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <p> 56eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <em> Data sources that VideoView2 supports : </em> 57df0728c15af0f6cc101883af097ffe680279448aInsun Kang * VideoView2 can play video files and audio-only files as 58eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * well. It can load from various sources such as resources or content providers. The supported 59b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * media file formats are the same as {@link MediaPlayer2}. 60eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 61eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <p> 62eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <em> View type can be selected : </em> 63eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * VideoView2 can render videos on top of TextureView as well as 64eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * SurfaceView selectively. The default is SurfaceView and it can be changed using 65eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@link #setViewType(int)} method. Using SurfaceView is recommended in most cases for saving 66eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * battery. TextureView might be preferred for supporting various UIs such as animation and 67eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * translucency. 68eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 69eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <p> 70eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <em> Differences between {@link VideoView} class : </em> 71eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * VideoView2 covers and inherits the most of 72eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * VideoView's functionalities. The main differences are 73eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <ul> 74eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li> VideoView2 inherits FrameLayout and renders videos using SurfaceView and TextureView 75eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * selectively while VideoView inherits SurfaceView class. 76eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li> VideoView2 is integrated with MediaControlView2 and a default MediaControlView2 instance is 77eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * attached to VideoView2 by default. If a developer does not want to use the default 78eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * MediaControlView2, needs to set enableControlView attribute to false. For instance, 79eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <pre> 80eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <VideoView2 81eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * android:id="@+id/video_view" 82eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * xmlns:widget="http://schemas.android.com/apk/com.android.media.update" 83eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * widget:enableControlView="false" /> 84eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * </pre> 85eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * If a developer wants to attach a customed MediaControlView2, then set enableControlView attribute 86eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * to false and assign the customed media control widget using {@link #setMediaControlView2}. 87eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li> VideoView2 is integrated with MediaPlayer2 while VideoView is integrated with MediaPlayer. 8882af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * <li> VideoView2 is integrated with MediaSession and so it responses with media key events. 8982af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * A VideoView2 keeps a MediaSession instance internally and connects it to a corresponding 90eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * MediaControlView2 instance. 91eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * </p> 92eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * </ul> 93eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 94eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <p> 95eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <em> Audio focus and audio attributes : </em> 96eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * By default, VideoView2 requests audio focus with 97eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@link AudioManager#AUDIOFOCUS_GAIN}. Use {@link #setAudioFocusRequest(int)} to change this 98eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * behavior. The default {@link AudioAttributes} used during playback have a usage of 99eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@link AudioAttributes#USAGE_MEDIA} and a content type of 100eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@link AudioAttributes#CONTENT_TYPE_MOVIE}, use {@link #setAudioAttributes(AudioAttributes)} to 101eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * modify them. 102eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 103eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <p> 104eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Note: VideoView2 does not retain its full state when going into the background. In particular, it 105eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * does not restore the current play state, play position, selected tracks. Applications should save 106eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * and restore these on their own in {@link android.app.Activity#onSaveInstanceState} and 107eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@link android.app.Activity#onRestoreInstanceState}. 108e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 109f38d8fb9344954ed28ccaaee8e29dcd4d65f1fe0Christofer Ã…kerstenpublic class VideoView2 extends ViewGroupHelper<VideoView2Provider> { 110eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang /** @hide */ 111e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim @IntDef({ 112e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim VIEW_TYPE_TEXTUREVIEW, 113e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim VIEW_TYPE_SURFACEVIEW 114e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim }) 115e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim @Retention(RetentionPolicy.SOURCE) 116e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public @interface ViewType {} 117eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang 118df0728c15af0f6cc101883af097ffe680279448aInsun Kang /** 1194fa8064378770a0e05b7462c173bfb74cb540f37Insun Kang * Indicates video is rendering on SurfaceView. 120df0728c15af0f6cc101883af097ffe680279448aInsun Kang * 121df0728c15af0f6cc101883af097ffe680279448aInsun Kang * @see #setViewType 122df0728c15af0f6cc101883af097ffe680279448aInsun Kang */ 123e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public static final int VIEW_TYPE_SURFACEVIEW = 1; 124df0728c15af0f6cc101883af097ffe680279448aInsun Kang 125df0728c15af0f6cc101883af097ffe680279448aInsun Kang /** 1264fa8064378770a0e05b7462c173bfb74cb540f37Insun Kang * Indicates video is rendering on TextureView. 127df0728c15af0f6cc101883af097ffe680279448aInsun Kang * 128df0728c15af0f6cc101883af097ffe680279448aInsun Kang * @see #setViewType 129df0728c15af0f6cc101883af097ffe680279448aInsun Kang */ 130e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public static final int VIEW_TYPE_TEXTUREVIEW = 2; 131e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 132e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public VideoView2(@NonNull Context context) { 133e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim this(context, null); 134e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 135e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 136e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public VideoView2(@NonNull Context context, @Nullable AttributeSet attrs) { 137e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim this(context, attrs, 0); 138e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 139e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 140e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public VideoView2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 141e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim this(context, attrs, defStyleAttr, 0); 142e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 143e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 144e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public VideoView2( 145e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim @NonNull Context context, @Nullable AttributeSet attrs, 146e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim int defStyleAttr, int defStyleRes) { 147f38d8fb9344954ed28ccaaee8e29dcd4d65f1fe0Christofer Ã…kersten super((instance, superProvider, privateProvider) -> 148a6c97e4615890f491f14f22409657b7b7d723dabChristofer Ã…kersten ApiLoader.getProvider(context).createVideoView2( 149f38d8fb9344954ed28ccaaee8e29dcd4d65f1fe0Christofer Ã…kersten (VideoView2) instance, superProvider, privateProvider, 150f38d8fb9344954ed28ccaaee8e29dcd4d65f1fe0Christofer Ã…kersten attrs, defStyleAttr, defStyleRes), 151a6c97e4615890f491f14f22409657b7b7d723dabChristofer Ã…kersten context, attrs, defStyleAttr, defStyleRes); 152f38d8fb9344954ed28ccaaee8e29dcd4d65f1fe0Christofer Ã…kersten mProvider.initialize(attrs, defStyleAttr, defStyleRes); 153e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 154e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 155e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 156eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Sets MediaControlView2 instance. It will replace the previously assigned MediaControlView2 157eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * instance if any. 158eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 159eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param mediaControlView a media control view2 instance. 160718c1d122f66ee0b95b8d7cc7f2988730d73461eInsun Kang * @param intervalMs a time interval in milliseconds until VideoView2 hides MediaControlView2. 161e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 162718c1d122f66ee0b95b8d7cc7f2988730d73461eInsun Kang public void setMediaControlView2(MediaControlView2 mediaControlView, long intervalMs) { 163718c1d122f66ee0b95b8d7cc7f2988730d73461eInsun Kang mProvider.setMediaControlView2_impl(mediaControlView, intervalMs); 164de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang } 165de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang 166de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang /** 167eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Returns MediaControlView2 instance which is currently attached to VideoView2 by default or by 168eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@link #setMediaControlView2} method. 169de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang */ 170de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang public MediaControlView2 getMediaControlView2() { 171de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang return mProvider.getMediaControlView2_impl(); 172de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang } 173de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang 174b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park /** 175b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * Sets MediaMetadata2 instance. It will replace the previously assigned MediaMetadata2 instance 176b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * if any. 177b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * 178b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * @param metadata a MediaMetadata2 instance. 179b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * @hide 180b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park */ 181b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park public void setMediaMetadata(MediaMetadata2 metadata) { 182b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park mProvider.setMediaMetadata_impl(metadata); 183b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park } 184b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park 185b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park /** 186b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * Returns MediaMetadata2 instance which is retrieved from MediaPlayer2 inside VideoView2 by 187b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * default or by {@link #setMediaMetadata} method. 188b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park * @hide 189b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park */ 190b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park public MediaMetadata2 getMediaMetadata() { 191b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park // TODO: add to Javadoc whether this value can be null or not when integrating with 192b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park // MediaSession2. 193b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park return mProvider.getMediaMetadata_impl(); 194b9f6febce41cbf0732c27e4f99ac4c18c7ef8272Jin Seok Park } 195e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 196e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 19782af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * Returns MediaController instance which is connected with MediaSession that VideoView2 is 19882af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * using. This method should be called when VideoView2 is attached to window, or it throws 19982af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * IllegalStateException, since internal MediaSession instance is not available until 20082af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * this view is attached to window. Please check {@link android.view.View#isAttachedToWindow} 20182af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * before calling this method. 20282af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * 20382af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim * @throws IllegalStateException if interal MediaSession is not created yet. 204b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO: remove 205e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 20682af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim public MediaController getMediaController() { 20782af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim return mProvider.getMediaController_impl(); 208e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 209e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 210e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 211b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * Returns {@link android.media.SessionToken2} so that developers create their own 212b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * {@link android.media.MediaController2} instance. This method should be called when VideoView2 213b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * is attached to window, or it throws IllegalStateException. 214b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * 215b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @throws IllegalStateException if interal MediaSession is not created yet. 216b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang */ 217b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang public SessionToken2 getMediaSessionToken() { 218b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang return mProvider.getMediaSessionToken_impl(); 219b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang } 220b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang 221b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang /** 2224fa8064378770a0e05b7462c173bfb74cb540f37Insun Kang * Shows or hides closed caption or subtitles if there is any. 223682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang * The first subtitle track will be chosen if there multiple subtitle tracks exist. 224682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang * Default behavior of VideoView2 is not showing subtitle. 225682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang * @param enable shows closed caption or subtitles if this value is true, or hides. 226e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 227682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang public void setSubtitleEnabled(boolean enable) { 228682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang mProvider.setSubtitleEnabled_impl(enable); 229682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang } 230682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang 231682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang /** 232682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang * Returns true if showing subtitle feature is enabled or returns false. 233682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang * Although there is no subtitle track or closed caption, it can return true, if the feature 234682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang * has been enabled by {@link #setSubtitleEnabled}. 235682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang */ 236682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang public boolean isSubtitleEnabled() { 237682483d1652bda42e653ea8aa4cbb9f8572c53e7Insun Kang return mProvider.isSubtitleEnabled_impl(); 238e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 239e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 240efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon /** 241de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * Sets playback speed. 242de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * 243de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * It is expressed as a multiplicative factor, where normal speed is 1.0f. If it is less than 244de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * or equal to zero, it will be just ignored and nothing will be changed. If it exceeds the 245de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * maximum speed that internal engine supports, system will determine best handling or it will 246de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * be reset to the normal speed 1.0f. 247de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * @param speed the playback speed. It should be positive. 248de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang */ 24982af545ca64bff030697a0369e0301c03e8123ecSungsoo Lim // TODO: Support this via MediaController2. 250de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang public void setSpeed(float speed) { 251de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang mProvider.setSpeed_impl(speed); 252de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang } 253de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang 254de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang /** 255de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * Sets which type of audio focus will be requested during the playback, or configures playback 256de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * to not request audio focus. Valid values for focus requests are 257de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * {@link AudioManager#AUDIOFOCUS_GAIN}, {@link AudioManager#AUDIOFOCUS_GAIN_TRANSIENT}, 258de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * {@link AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK}, and 259de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * {@link AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE}. Or use 260de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * {@link AudioManager#AUDIOFOCUS_NONE} to express that audio focus should not be 261de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * requested when playback starts. You can for instance use this when playing a silent animation 262de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * through this class, and you don't want to affect other audio applications playing in the 263de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * background. 264de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * 265de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * @param focusGain the type of audio focus gain that will be requested, or 266af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * {@link AudioManager#AUDIOFOCUS_NONE} to disable the use audio focus during 267af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * playback. 268e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 269e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public void setAudioFocusRequest(int focusGain) { 270e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim mProvider.setAudioFocusRequest_impl(focusGain); 271e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 272e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 273e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 274de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * Sets the {@link AudioAttributes} to be used during the playback of the video. 275de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * 276de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * @param attributes non-null <code>AudioAttributes</code>. 277e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 278e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public void setAudioAttributes(@NonNull AudioAttributes attributes) { 279e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim mProvider.setAudioAttributes_impl(attributes); 280e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 281e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 282b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang // TODO: unhide this method when MediaPlayerInterface became unhidden. 283e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 284af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * Sets a remote player for handling playback of the selected route from MediaControlView2. 285af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * If this is not called, MediaCotrolView2 will not show the route button. 286af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * 287af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * @param routeCategories the list of media control categories in 288af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * {@link android.support.v7.media.MediaControlIntent} 289d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * @param player the player to handle playback of the selected route. 290d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * If null, a default route player will be used. 291af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim * @throws IllegalStateException if MediaControlView2 is not set. 292d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * @hide 293af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim */ 294af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim public void setRouteAttributes(@NonNull List<String> routeCategories, 2956cc1a5de46ec18172d75ac589dbe8b306d0fb8d2Jaewan Kim @Nullable MediaPlayerBase player) { 296af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim mProvider.setRouteAttributes_impl(routeCategories, player); 297af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim } 298af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim 299af2a1ad069f2fefc162eede7556cd91288a91e8cSungsoo Lim /** 300d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * Sets a remote player for handling playback of the selected route from MediaControlView2. 301d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * If this is not called, MediaCotrolView2 will not show the route button. 302d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * 303d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * @param routeCategories the list of media control categories in 304d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * {@link android.support.v7.media.MediaControlIntent} 305d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * @param sessionPlayer the player to handle playback of the selected route. 306d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * If null, a default route player will be used. 307d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * @throws IllegalStateException if MediaControlView2 is not set. 308d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim * @hide 309d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim */ 310d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim // TODO: Use MediaPlayerBase once MediaSession2 APIs are ready. 311d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim public void setRouteAttributes(@NonNull List<String> routeCategories, 312d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim @Nullable MediaSession.Callback sessionPlayer) { 313d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim mProvider.setRouteAttributes_impl(routeCategories, sessionPlayer); 314d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim } 315d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim 316d58f145726a7ef76e4b35dcb528d91549e457e4eSungsoo Lim /** 317de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * Sets video path. 318de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * 319de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * @param path the path of the video. 320b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * 321b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 322e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 323e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public void setVideoPath(String path) { 324e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim mProvider.setVideoPath_impl(path); 325e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 326e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 327e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 328eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Sets video URI. 329eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 330eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param uri the URI of the video. 331b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * 332b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 333e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 334df0728c15af0f6cc101883af097ffe680279448aInsun Kang public void setVideoUri(Uri uri) { 335df0728c15af0f6cc101883af097ffe680279448aInsun Kang mProvider.setVideoUri_impl(uri); 336e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 337e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 338e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 339eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Sets video URI using specific headers. 340eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 341eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param uri the URI of the video. 342eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param headers the headers for the URI request. 343eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Note that the cross domain redirection is allowed by default, but that can be 344eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * changed with key/value pairs through the headers parameter with 345eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * "android-allow-cross-domain-redirect" as the key and "0" or "1" as the value 346eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * to disallow or allow cross domain redirection. 347b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * 348b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 349e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 350df0728c15af0f6cc101883af097ffe680279448aInsun Kang public void setVideoUri(Uri uri, Map<String, String> headers) { 351df0728c15af0f6cc101883af097ffe680279448aInsun Kang mProvider.setVideoUri_impl(uri, headers); 352e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 353e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 354e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 355b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * Sets {@link MediaItem2} object to render using VideoView2. Alternative way to set media 356b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * object to VideoView2 is {@link #setDataSource}. 357b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @param mediaItem the MediaItem2 to play 358b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @see #setDataSource 359b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang */ 360b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang public void setMediaItem(@NonNull MediaItem2 mediaItem) { 361b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang mProvider.setMediaItem_impl(mediaItem); 362b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang } 363b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang 364b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang /** 365b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * Sets {@link DataSourceDesc} object to render using VideoView2. 366b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @param dataSource the {@link DataSourceDesc} object to play. 367b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @see #setMediaItem 368b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang */ 369b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang public void setDataSource(@NonNull DataSourceDesc dataSource) { 370b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang mProvider.setDataSource_impl(dataSource); 371b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang } 372b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang 373b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang /** 374eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Selects which view will be used to render video between SurfacView and TextureView. 375eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 376eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param viewType the view type to render video 377eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <ul> 378eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li>{@link #VIEW_TYPE_SURFACEVIEW} 379eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li>{@link #VIEW_TYPE_TEXTUREVIEW} 380eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * </ul> 381e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 382e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public void setViewType(@ViewType int viewType) { 383e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim mProvider.setViewType_impl(viewType); 384e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 385e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 386e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 387eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Returns view type. 388eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * 389eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @return view type. See {@see setViewType}. 390e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 391e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim @ViewType 392e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public int getViewType() { 393e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim return mProvider.getViewType_impl(); 394e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 395e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 396e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 39746377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * Sets custom actions which will be shown as custom buttons in {@link MediaControlView2}. 39846377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * 39946377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * @param actionList A list of {@link PlaybackState.CustomAction}. The return value of 40046377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * {@link PlaybackState.CustomAction#getIcon()} will be used to draw buttons 40146377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * in {@link MediaControlView2}. 402620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang * @param executor executor to run callbacks on. 40346377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * @param listener A listener to be called when a custom button is clicked. 404b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 40546377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon */ 40646377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon public void setCustomActions(List<PlaybackState.CustomAction> actionList, 407620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang Executor executor, OnCustomActionListener listener) { 408620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang mProvider.setCustomActions_impl(actionList, executor, listener); 40946377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon } 41046377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon 41146377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon /** 412eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * Registers a callback to be invoked when a view type change is done. 413eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * {@see #setViewType(int)} 414eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param l The callback that will be run 415a35d1b194696ff73970b640446b2391711ea6030Insun Kang * @hide 416e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 417a35d1b194696ff73970b640446b2391711ea6030Insun Kang @VisibleForTesting 418a35d1b194696ff73970b640446b2391711ea6030Insun Kang public void setOnViewTypeChangedListener(OnViewTypeChangedListener l) { 419a35d1b194696ff73970b640446b2391711ea6030Insun Kang mProvider.setOnViewTypeChangedListener_impl(l); 420e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 421e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 422e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 423efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon * Registers a callback to be invoked when the fullscreen mode should be changed. 424620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang * @param l The callback that will be run 425b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 426efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon */ 427a35d1b194696ff73970b640446b2391711ea6030Insun Kang public void setFullScreenRequestListener(OnFullScreenRequestListener l) { 428a35d1b194696ff73970b640446b2391711ea6030Insun Kang mProvider.setFullScreenRequestListener_impl(l); 429efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon } 430efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon 431efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon /** 432df0728c15af0f6cc101883af097ffe680279448aInsun Kang * Interface definition of a callback to be invoked when the view type has been changed. 433a35d1b194696ff73970b640446b2391711ea6030Insun Kang * 434a35d1b194696ff73970b640446b2391711ea6030Insun Kang * @hide 435e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 436a35d1b194696ff73970b640446b2391711ea6030Insun Kang @VisibleForTesting 437e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim public interface OnViewTypeChangedListener { 438e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim /** 439de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang * Called when the view type has been changed. 440eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @see #setViewType(int) 441df0728c15af0f6cc101883af097ffe680279448aInsun Kang * @param view the View whose view type is changed 442eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * @param viewType 443eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <ul> 444eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li>{@link #VIEW_TYPE_SURFACEVIEW} 445eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * <li>{@link #VIEW_TYPE_TEXTUREVIEW} 446eb78d511cb5b06e7c679a090fc13afd74ec15717Insun Kang * </ul> 447e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim */ 448df0728c15af0f6cc101883af097ffe680279448aInsun Kang void onViewTypeChanged(View view, @ViewType int viewType); 449e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim } 450e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim 451de16c4d3579238b49cd3a253e9905196120f9bf0Insun Kang /** 452efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon * Interface definition of a callback to be invoked to inform the fullscreen mode is changed. 453620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang * Application should handle the fullscreen mode accordingly. 454b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 455efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon */ 456620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang public interface OnFullScreenRequestListener { 457efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon /** 458efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon * Called to indicate a fullscreen mode change. 459efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon */ 460620b7f328f6e621da4c8fe6695b479bebd147cdbInsun Kang void onFullScreenRequest(View view, boolean fullScreen); 461efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon } 462efeb45eabd6b9b2bcb8390e4140c615967c70ddaHyundo Moon 46346377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon /** 46446377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * Interface definition of a callback to be invoked to inform that a custom action is performed. 465b785faa1d71d64bba56e34dce93c7e8937845afcInsun Kang * @hide TODO remove 46646377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon */ 46746377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon public interface OnCustomActionListener { 46846377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon /** 46946377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * Called to indicate that a custom action is performed. 47046377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * 47146377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * @param action The action that was originally sent in the 47246377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * {@link PlaybackState.CustomAction}. 47346377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon * @param extras Optional extras. 47446377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon */ 47546377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon void onCustomAction(String action, Bundle extras); 47646377a9aaea75f5dfc3b9365142c6e65398e2afeHyundo Moon } 4778589b7b34bd79d74ad4af218c162f63650161882Insun Kang 4788589b7b34bd79d74ad4af218c162f63650161882Insun Kang @Override 4798589b7b34bd79d74ad4af218c162f63650161882Insun Kang protected void onLayout(boolean changed, int l, int t, int r, int b) { 4808589b7b34bd79d74ad4af218c162f63650161882Insun Kang mProvider.onLayout_impl(changed, l, t, r, b); 4818589b7b34bd79d74ad4af218c162f63650161882Insun Kang } 482e3259049872ea9000b71e8f14d4237a75bc9d606Sungsoo Lim} 483