/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.content.Context; import android.media.session.MediaController; import android.media.update.ApiLoader; import android.media.update.FrameLayoutHelper; import android.media.update.MediaControlView2Provider; import android.util.AttributeSet; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * A View that contains the controls for MediaPlayer2. * It provides a wide range of UI including buttons such as "Play/Pause", "Rewind", "Fast Forward", * "Subtitle", "Full Screen", and it is also possible to add multiple custom buttons. * *
* MediaControlView2 can be initialized in two different ways: * 1) When VideoView2 is initialized, it automatically initializes a MediaControlView2 instance and * adds it to the view. * 2) Initialize MediaControlView2 programmatically and add it to a ViewGroup instance. * * In the first option, VideoView2 automatically connects MediaControlView2 to MediaController, * which is necessary to communicate with MediaSession2. In the second option, however, the * developer needs to manually retrieve a MediaController instance and set it to MediaControlView2 * by calling setController(MediaController controller). * *
* There is no separate method that handles the show/hide behavior for MediaControlView2. Instead, * one can directly change the visibility of this view by calling View.setVisibility(int). The * values supported are View.VISIBLE and View.GONE. * In addition, the following customizations are supported: * 1. Modify default timeout value of 2 seconds by calling setTimeout(long). * 2. Set focus to the play/pause button by calling requestPlayButtonFocus(). * *
* It is also possible to add custom buttons with custom icons and actions inside MediaControlView2.
* Those buttons will be shown when the overflow button is clicked.
* See {@link VideoView2#setCustomActions} for more details on how to add.
*
* TODO PUBLIC API
* @hide
*/
public class MediaControlView2 extends FrameLayoutHelper
*
* @param visibility One of {@link #VISIBLE}, {@link #INVISIBLE}, or {@link #GONE}.
*/
public void setButtonVisibility(@Button int button, @Visibility int visibility) {
mProvider.setButtonVisibility_impl(button, visibility);
}
/**
* Requests focus for the play/pause button.
*/
public void requestPlayButtonFocus() {
mProvider.requestPlayButtonFocus_impl();
}
/**
* Sets a new timeout value (in milliseconds) for showing MediaControlView2. The default value
* is set as 2 seconds.
* @param timeout the
*/
public void setTimeout(long timeout) {
mProvider.setTimeout_impl(timeout);
}
/**
* Retrieves current timeout value (in milliseconds) for showing MediaControlView2. The default
* value is set as 2 seconds.
*/
public long getTimeout() {
return mProvider.getTimeout_impl();
}
@Override
// TODO Move this method to ViewProvider
public void onVisibilityAggregated(boolean isVisible) {
mProvider.onVisibilityAggregated_impl(isVisible);
}
}