mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Rename StyledPlayerView to PlayerView
This commit leaves some 'styled' references, specifically: * exo_styled_XXX dimension names * exo_styled_controls_XXX drawable IDs * exo_styled_XXX color names * ExoStyledControls.XXX style names PiperOrigin-RevId: 421576554
This commit is contained in:
parent
4d5bf7c065
commit
bfce8f5456
22 changed files with 128 additions and 134 deletions
|
|
@ -36,7 +36,7 @@ import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
import androidx.media3.ui.StyledPlayerView;
|
import androidx.media3.ui.PlayerView;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
@ -52,7 +52,7 @@ import com.google.android.gms.dynamite.DynamiteModule;
|
||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity
|
||||||
implements OnClickListener, PlayerManager.Listener {
|
implements OnClickListener, PlayerManager.Listener {
|
||||||
|
|
||||||
private StyledPlayerView playerView;
|
private PlayerView playerView;
|
||||||
private PlayerManager playerManager;
|
private PlayerManager playerManager;
|
||||||
private RecyclerView mediaQueueList;
|
private RecyclerView mediaQueueList;
|
||||||
private MediaQueueListAdapter mediaQueueListAdapter;
|
private MediaQueueListAdapter mediaQueueListAdapter;
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ import androidx.media3.common.Player.TimelineChangeReason;
|
||||||
import androidx.media3.common.Timeline;
|
import androidx.media3.common.Timeline;
|
||||||
import androidx.media3.common.TracksInfo;
|
import androidx.media3.common.TracksInfo;
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
import androidx.media3.ui.StyledPlayerControlView;
|
import androidx.media3.ui.PlayerControlView;
|
||||||
import androidx.media3.ui.StyledPlayerView;
|
import androidx.media3.ui.PlayerView;
|
||||||
import com.google.android.gms.cast.framework.CastContext;
|
import com.google.android.gms.cast.framework.CastContext;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ import java.util.ArrayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final StyledPlayerView playerView;
|
private final PlayerView playerView;
|
||||||
private final Player localPlayer;
|
private final Player localPlayer;
|
||||||
private final CastPlayer castPlayer;
|
private final CastPlayer castPlayer;
|
||||||
private final ArrayList<MediaItem> mediaQueue;
|
private final ArrayList<MediaItem> mediaQueue;
|
||||||
|
|
@ -66,11 +66,11 @@ import java.util.ArrayList;
|
||||||
*
|
*
|
||||||
* @param context A {@link Context}.
|
* @param context A {@link Context}.
|
||||||
* @param listener A {@link Listener} for queue position changes.
|
* @param listener A {@link Listener} for queue position changes.
|
||||||
* @param playerView The {@link StyledPlayerView} for playback.
|
* @param playerView The {@link PlayerView} for playback.
|
||||||
* @param castContext The {@link CastContext}.
|
* @param castContext The {@link CastContext}.
|
||||||
*/
|
*/
|
||||||
public PlayerManager(
|
public PlayerManager(
|
||||||
Context context, Listener listener, StyledPlayerView playerView, CastContext castContext) {
|
Context context, Listener listener, PlayerView playerView, CastContext castContext) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.playerView = playerView;
|
this.playerView = playerView;
|
||||||
|
|
@ -270,7 +270,7 @@ import java.util.ArrayList;
|
||||||
R.drawable.ic_baseline_cast_connected_400,
|
R.drawable.ic_baseline_cast_connected_400,
|
||||||
/* theme= */ null));
|
/* theme= */ null));
|
||||||
} else { // currentPlayer == localPlayer
|
} else { // currentPlayer == localPlayer
|
||||||
playerView.setControllerShowTimeoutMs(StyledPlayerControlView.DEFAULT_SHOW_TIMEOUT_MS);
|
playerView.setControllerShowTimeoutMs(PlayerControlView.DEFAULT_SHOW_TIMEOUT_MS);
|
||||||
playerView.setDefaultArtwork(null);
|
playerView.setDefaultArtwork(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:keepScreenOn="true">
|
android:keepScreenOn="true">
|
||||||
|
|
||||||
<androidx.media3.ui.StyledPlayerView android:id="@+id/player_view"
|
<androidx.media3.ui.PlayerView android:id="@+id/player_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import androidx.media3.exoplayer.drm.HttpMediaDrmCallback;
|
||||||
import androidx.media3.exoplayer.source.MediaSource;
|
import androidx.media3.exoplayer.source.MediaSource;
|
||||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource;
|
import androidx.media3.exoplayer.source.ProgressiveMediaSource;
|
||||||
import androidx.media3.exoplayer.util.EventLogger;
|
import androidx.media3.exoplayer.util.EventLogger;
|
||||||
import androidx.media3.ui.StyledPlayerView;
|
import androidx.media3.ui.PlayerView;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -61,7 +61,7 @@ public final class MainActivity extends Activity {
|
||||||
private static final String DRM_SCHEME_EXTRA = "drm_scheme";
|
private static final String DRM_SCHEME_EXTRA = "drm_scheme";
|
||||||
private static final String DRM_LICENSE_URL_EXTRA = "drm_license_url";
|
private static final String DRM_LICENSE_URL_EXTRA = "drm_license_url";
|
||||||
|
|
||||||
@Nullable private StyledPlayerView playerView;
|
@Nullable private PlayerView playerView;
|
||||||
@Nullable private VideoProcessingGLSurfaceView videoProcessingGLSurfaceView;
|
@Nullable private VideoProcessingGLSurfaceView videoProcessingGLSurfaceView;
|
||||||
|
|
||||||
@Nullable private ExoPlayer player;
|
@Nullable private ExoPlayer player;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:keepScreenOn="true">
|
android:keepScreenOn="true">
|
||||||
|
|
||||||
<androidx.media3.ui.StyledPlayerView
|
<androidx.media3.ui.PlayerView
|
||||||
android:id="@+id/player_view"
|
android:id="@+id/player_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
||||||
|
|
@ -52,15 +52,15 @@ import androidx.media3.exoplayer.source.ads.AdsLoader;
|
||||||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
|
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
|
||||||
import androidx.media3.exoplayer.util.DebugTextViewHelper;
|
import androidx.media3.exoplayer.util.DebugTextViewHelper;
|
||||||
import androidx.media3.exoplayer.util.EventLogger;
|
import androidx.media3.exoplayer.util.EventLogger;
|
||||||
import androidx.media3.ui.StyledPlayerControlView;
|
import androidx.media3.ui.PlayerControlView;
|
||||||
import androidx.media3.ui.StyledPlayerView;
|
import androidx.media3.ui.PlayerView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** An activity that plays media using {@link ExoPlayer}. */
|
/** An activity that plays media using {@link ExoPlayer}. */
|
||||||
public class PlayerActivity extends AppCompatActivity
|
public class PlayerActivity extends AppCompatActivity
|
||||||
implements OnClickListener, StyledPlayerControlView.VisibilityListener {
|
implements OnClickListener, PlayerControlView.VisibilityListener {
|
||||||
|
|
||||||
// Saved instance state keys.
|
// Saved instance state keys.
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
private static final String KEY_POSITION = "position";
|
private static final String KEY_POSITION = "position";
|
||||||
private static final String KEY_AUTO_PLAY = "auto_play";
|
private static final String KEY_AUTO_PLAY = "auto_play";
|
||||||
|
|
||||||
protected StyledPlayerView playerView;
|
protected PlayerView playerView;
|
||||||
protected LinearLayout debugRootView;
|
protected LinearLayout debugRootView;
|
||||||
protected TextView debugTextView;
|
protected TextView debugTextView;
|
||||||
protected @Nullable ExoPlayer player;
|
protected @Nullable ExoPlayer player;
|
||||||
|
|
@ -234,7 +234,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyledPlayerControlView.VisibilityListener implementation
|
// PlayerControlView.VisibilityListener implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVisibilityChange(int visibility) {
|
public void onVisibilityChange(int visibility) {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:keepScreenOn="true">
|
android:keepScreenOn="true">
|
||||||
|
|
||||||
<androidx.media3.ui.StyledPlayerView android:id="@+id/player_view"
|
<androidx.media3.ui.PlayerView android:id="@+id/player_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_shuffle_button="true"
|
app:show_shuffle_button="true"
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import androidx.media3.common.MediaMetadata
|
||||||
import androidx.media3.common.Player
|
import androidx.media3.common.Player
|
||||||
import androidx.media3.session.MediaController
|
import androidx.media3.session.MediaController
|
||||||
import androidx.media3.session.SessionToken
|
import androidx.media3.session.SessionToken
|
||||||
import androidx.media3.ui.StyledPlayerView
|
import androidx.media3.ui.PlayerView
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import com.google.common.util.concurrent.MoreExecutors
|
import com.google.common.util.concurrent.MoreExecutors
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
private val controller: MediaController?
|
private val controller: MediaController?
|
||||||
get() = if (controllerFuture.isDone) controllerFuture.get() else null
|
get() = if (controllerFuture.isDone) controllerFuture.get() else null
|
||||||
|
|
||||||
private lateinit var playerView: StyledPlayerView
|
private lateinit var playerView: PlayerView
|
||||||
private lateinit var mediaList: ListView
|
private lateinit var mediaList: ListView
|
||||||
private lateinit var mediaListAdapter: PlayingMediaItemArrayAdapter
|
private lateinit var mediaListAdapter: PlayingMediaItemArrayAdapter
|
||||||
private val subItemMediaList: MutableList<MediaItem> = mutableListOf()
|
private val subItemMediaList: MutableList<MediaItem> = mutableListOf()
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
android:layout_height="300dp"
|
android:layout_height="300dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
>
|
>
|
||||||
<androidx.media3.ui.StyledPlayerView
|
<androidx.media3.ui.PlayerView
|
||||||
android:id="@+id/player_view"
|
android:id="@+id/player_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -104,20 +104,20 @@ gets from the libgav1 decoder:
|
||||||
|
|
||||||
* GL rendering using GL shader for color space conversion
|
* GL rendering using GL shader for color space conversion
|
||||||
|
|
||||||
* If you are using `ExoPlayer` with `LegacyPlayerView` or
|
* If you are using `ExoPlayer` with `LegacyPlayerView` or `PlayerView`,
|
||||||
`StyledPlayerView`, enable this option by setting `surface_type` of view
|
enable this option by setting `surface_type` of view to be
|
||||||
to be `video_decoder_gl_surface_view`.
|
`video_decoder_gl_surface_view`.
|
||||||
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a
|
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a
|
||||||
message of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
message of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
||||||
`VideoDecoderOutputBufferRenderer` as its object.
|
`VideoDecoderOutputBufferRenderer` as its object.
|
||||||
`VideoDecoderGLSurfaceView` is the concrete
|
`VideoDecoderGLSurfaceView` is the concrete
|
||||||
`VideoDecoderOutputBufferRenderer` implementation used by
|
`VideoDecoderOutputBufferRenderer` implementation used by `PlayerView`
|
||||||
`StyledPlayerView` and `LegacyPlayerView`.
|
and `LegacyPlayerView`.
|
||||||
|
|
||||||
* Native rendering using `ANativeWindow`
|
* Native rendering using `ANativeWindow`
|
||||||
|
|
||||||
* If you are using `ExoPlayer` with `LegacyPlayerView` or
|
* If you are using `ExoPlayer` with `LegacyPlayerView` or `PlayerView`,
|
||||||
`StyledPlayerView`, this option is enabled by default.
|
this option is enabled by default.
|
||||||
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a
|
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a
|
||||||
message of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
message of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
||||||
`SurfaceView` as its object.
|
`SurfaceView` as its object.
|
||||||
|
|
|
||||||
|
|
@ -117,20 +117,20 @@ gets from the libvpx decoder:
|
||||||
|
|
||||||
* GL rendering using GL shader for color space conversion
|
* GL rendering using GL shader for color space conversion
|
||||||
|
|
||||||
* If you are using `ExoPlayer` with `LegacyPlayerView` or
|
* If you are using `ExoPlayer` with `LegacyPlayerView` or `PlayerView`,
|
||||||
`StyledPlayerView`, enable this option by setting `surface_type` of view
|
enable this option by setting `surface_type` of view to be
|
||||||
to be `video_decoder_gl_surface_view`.
|
`video_decoder_gl_surface_view`.
|
||||||
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message
|
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message
|
||||||
of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
||||||
`VideoDecoderOutputBufferRenderer` as its object.
|
`VideoDecoderOutputBufferRenderer` as its object.
|
||||||
`VideoDecoderGLSurfaceView` is the concrete
|
`VideoDecoderGLSurfaceView` is the concrete
|
||||||
`VideoDecoderOutputBufferRenderer` implementation used by
|
`VideoDecoderOutputBufferRenderer` implementation used by `PlayerView`
|
||||||
`StyledPlayerView` and `LegacyPlayerView`.
|
and `LegacyPlayerView`.
|
||||||
|
|
||||||
* Native rendering using `ANativeWindow`
|
* Native rendering using `ANativeWindow`
|
||||||
|
|
||||||
* If you are using `ExoPlayer` with `LegacyPlayerView` or
|
* If you are using `ExoPlayer` with `LegacyPlayerView` or `PlayerView`,
|
||||||
`StyledPlayerView`, this option is enabled by default.
|
this option is enabled by default.
|
||||||
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message
|
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message
|
||||||
of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
|
||||||
`SurfaceView` as its object.
|
`SurfaceView` as its object.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Proguard rules specific to the UI module.
|
# Proguard rules specific to the UI module.
|
||||||
|
|
||||||
# Constructor method accessed via reflection in StyledPlayerView and LegacyPlayerView
|
# Constructor method accessed via reflection in PlayerView and LegacyPlayerView
|
||||||
-dontnote androidx.media3.exoplayer.video.spherical.SphericalGLSurfaceView
|
-dontnote androidx.media3.exoplayer.video.spherical.SphericalGLSurfaceView
|
||||||
-keepclassmembers class androidx.media3.exoplayer.video.spherical.SphericalGLSurfaceView {
|
-keepclassmembers class androidx.media3.exoplayer.video.spherical.SphericalGLSurfaceView {
|
||||||
<init>(android.content.Context);
|
<init>(android.content.Context);
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
* below for more details.
|
* below for more details.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Corresponding method: None
|
* <li>Corresponding method: None
|
||||||
* <li>Default: {@code R.layout.exo_styled_player_control_view}
|
* <li>Default: {@code R.layout.exo_player_control_view}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li>All attributes that can be set on {@link DefaultTimeBar} can also be set on a
|
* <li>All attributes that can be set on {@link DefaultTimeBar} can also be set on a
|
||||||
* StyledPlayerControlView, and will be propagated to the inflated {@link DefaultTimeBar}
|
* StyledPlayerControlView, and will be propagated to the inflated {@link DefaultTimeBar}
|
||||||
|
|
@ -193,7 +193,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
* <h2>Overriding the layout file</h2>
|
* <h2>Overriding the layout file</h2>
|
||||||
*
|
*
|
||||||
* To customize the layout of StyledPlayerControlView throughout your app, or just for certain
|
* To customize the layout of StyledPlayerControlView throughout your app, or just for certain
|
||||||
* configurations, you can define {@code exo_styled_player_control_view.xml} layout files in your
|
* configurations, you can define {@code exo_player_control_view.xml} layout files in your
|
||||||
* application {@code res/layout*} directories. But, in this case, you need to be careful since the
|
* application {@code res/layout*} directories. But, in this case, you need to be careful since the
|
||||||
* default animation implementation expects certain relative positions between children. See also <a
|
* default animation implementation expects certain relative positions between children. See also <a
|
||||||
* href="CustomLayout">Specifying a custom layout file</a>.
|
* href="CustomLayout">Specifying a custom layout file</a>.
|
||||||
|
|
@ -297,18 +297,18 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
*
|
*
|
||||||
* <h2 id="CustomLayout">Specifying a custom layout file</h2>
|
* <h2 id="CustomLayout">Specifying a custom layout file</h2>
|
||||||
*
|
*
|
||||||
* Defining your own {@code exo_styled_player_control_view.xml} is useful to customize the layout of
|
* Defining your own {@code exo_player_control_view.xml} is useful to customize the layout of
|
||||||
* StyledPlayerControlView throughout your application. It's also possible to customize the layout
|
* StyledPlayerControlView throughout your application. It's also possible to customize the layout
|
||||||
* for a single instance in a layout file. This is achieved by setting the {@code
|
* for a single instance in a layout file. This is achieved by setting the {@code
|
||||||
* controller_layout_id} attribute on a StyledPlayerControlView. This will cause the specified
|
* controller_layout_id} attribute on a StyledPlayerControlView. This will cause the specified
|
||||||
* layout to be inflated instead of {@code exo_styled_player_control_view.xml} for only the instance
|
* layout to be inflated instead of {@code exo_player_control_view.xml} for only the instance on
|
||||||
* on which the attribute is set.
|
* which the attribute is set.
|
||||||
*
|
*
|
||||||
* <p>You need to be careful when you set the {@code controller_layout_id}, because the default
|
* <p>You need to be careful when you set the {@code controller_layout_id}, because the default
|
||||||
* animation implementation expects certain relative positions between children.
|
* animation implementation expects certain relative positions between children.
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public class StyledPlayerControlView extends FrameLayout {
|
public class PlayerControlView extends FrameLayout {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
MediaLibraryInfo.registerModule("media3.ui");
|
MediaLibraryInfo.registerModule("media3.ui");
|
||||||
|
|
@ -426,7 +426,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
private boolean[] extraPlayedAdGroups;
|
private boolean[] extraPlayedAdGroups;
|
||||||
private long currentWindowOffset;
|
private long currentWindowOffset;
|
||||||
|
|
||||||
private StyledPlayerControlViewLayoutManager controlViewLayoutManager;
|
private PlayerControlViewLayoutManager controlViewLayoutManager;
|
||||||
private Resources resources;
|
private Resources resources;
|
||||||
|
|
||||||
private RecyclerView settingsView;
|
private RecyclerView settingsView;
|
||||||
|
|
@ -448,15 +448,15 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
@Nullable private View playbackSpeedButton;
|
@Nullable private View playbackSpeedButton;
|
||||||
@Nullable private View audioTrackButton;
|
@Nullable private View audioTrackButton;
|
||||||
|
|
||||||
public StyledPlayerControlView(Context context) {
|
public PlayerControlView(Context context) {
|
||||||
this(context, /* attrs= */ null);
|
this(context, /* attrs= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StyledPlayerControlView(Context context, @Nullable AttributeSet attrs) {
|
public PlayerControlView(Context context, @Nullable AttributeSet attrs) {
|
||||||
this(context, attrs, /* defStyleAttr= */ 0);
|
this(context, attrs, /* defStyleAttr= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StyledPlayerControlView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
public PlayerControlView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
this(context, attrs, defStyleAttr, attrs);
|
this(context, attrs, defStyleAttr, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -466,13 +466,13 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
"nullness:method.invocation",
|
"nullness:method.invocation",
|
||||||
"nullness:methodref.receiver.bound"
|
"nullness:methodref.receiver.bound"
|
||||||
})
|
})
|
||||||
public StyledPlayerControlView(
|
public PlayerControlView(
|
||||||
Context context,
|
Context context,
|
||||||
@Nullable AttributeSet attrs,
|
@Nullable AttributeSet attrs,
|
||||||
int defStyleAttr,
|
int defStyleAttr,
|
||||||
@Nullable AttributeSet playbackAttrs) {
|
@Nullable AttributeSet playbackAttrs) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
int controllerLayoutId = R.layout.exo_styled_player_control_view;
|
int controllerLayoutId = R.layout.exo_player_control_view;
|
||||||
showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS;
|
showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS;
|
||||||
repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES;
|
repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES;
|
||||||
timeBarMinUpdateIntervalMs = DEFAULT_TIME_BAR_MIN_UPDATE_INTERVAL_MS;
|
timeBarMinUpdateIntervalMs = DEFAULT_TIME_BAR_MIN_UPDATE_INTERVAL_MS;
|
||||||
|
|
@ -646,7 +646,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
updateButton(/* enabled= */ false, vrButton);
|
updateButton(/* enabled= */ false, vrButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
controlViewLayoutManager = new StyledPlayerControlViewLayoutManager(this);
|
controlViewLayoutManager = new PlayerControlViewLayoutManager(this);
|
||||||
controlViewLayoutManager.setAnimationEnabled(animationEnabled);
|
controlViewLayoutManager.setAnimationEnabled(animationEnabled);
|
||||||
|
|
||||||
String[] settingTexts = new String[2];
|
String[] settingTexts = new String[2];
|
||||||
|
|
@ -1767,7 +1767,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@Nullable Player player = StyledPlayerControlView.this.player;
|
@Nullable Player player = PlayerControlView.this.player;
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ import androidx.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/* package */ final class StyledPlayerControlViewLayoutManager {
|
/* package */ final class PlayerControlViewLayoutManager {
|
||||||
private static final long ANIMATION_INTERVAL_MS = 2_000;
|
private static final long ANIMATION_INTERVAL_MS = 2_000;
|
||||||
private static final long DURATION_FOR_HIDING_ANIMATION_MS = 250;
|
private static final long DURATION_FOR_HIDING_ANIMATION_MS = 250;
|
||||||
private static final long DURATION_FOR_SHOWING_ANIMATION_MS = 250;
|
private static final long DURATION_FOR_SHOWING_ANIMATION_MS = 250;
|
||||||
|
|
@ -48,7 +48,7 @@ import java.util.List;
|
||||||
// Int for defining the UX state where the views are being animated to be shown.
|
// Int for defining the UX state where the views are being animated to be shown.
|
||||||
private static final int UX_STATE_ANIMATING_SHOW = 4;
|
private static final int UX_STATE_ANIMATING_SHOW = 4;
|
||||||
|
|
||||||
private final StyledPlayerControlView playerControlView;
|
private final PlayerControlView playerControlView;
|
||||||
|
|
||||||
@Nullable private final View controlsBackground;
|
@Nullable private final View controlsBackground;
|
||||||
@Nullable private final ViewGroup centerControls;
|
@Nullable private final ViewGroup centerControls;
|
||||||
|
|
@ -84,7 +84,7 @@ import java.util.List;
|
||||||
private boolean animationEnabled;
|
private boolean animationEnabled;
|
||||||
|
|
||||||
@SuppressWarnings({"nullness:method.invocation", "nullness:methodref.receiver.bound"})
|
@SuppressWarnings({"nullness:method.invocation", "nullness:methodref.receiver.bound"})
|
||||||
public StyledPlayerControlViewLayoutManager(StyledPlayerControlView playerControlView) {
|
public PlayerControlViewLayoutManager(PlayerControlView playerControlView) {
|
||||||
this.playerControlView = playerControlView;
|
this.playerControlView = playerControlView;
|
||||||
showAllBarsRunnable = this::showAllBars;
|
showAllBarsRunnable = this::showAllBars;
|
||||||
hideAllBarsRunnable = this::hideAllBars;
|
hideAllBarsRunnable = this::hideAllBars;
|
||||||
|
|
@ -75,15 +75,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A high level view for {@link Player} media playbacks. It displays video, subtitles and album art
|
* A high level view for {@link Player} media playbacks. It displays video, subtitles and album art
|
||||||
* during playback, and displays playback controls using a {@link StyledPlayerControlView}.
|
* during playback, and displays playback controls using a {@link PlayerControlView}.
|
||||||
*
|
*
|
||||||
* <p>A StyledPlayerView can be customized by setting attributes (or calling corresponding methods),
|
* <p>A PlayerView can be customized by setting attributes (or calling corresponding methods),
|
||||||
* overriding drawables, overriding the view's layout file, or by specifying a custom view layout
|
* overriding drawables, overriding the view's layout file, or by specifying a custom view layout
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* <h2>Attributes</h2>
|
* <h2>Attributes</h2>
|
||||||
*
|
*
|
||||||
* The following attributes can be set on a StyledPlayerView when used in a layout XML file:
|
* The following attributes can be set on a PlayerView when used in a layout XML file:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><b>{@code use_artwork}</b> - Whether artwork is used if available in audio streams.
|
* <li><b>{@code use_artwork}</b> - Whether artwork is used if available in audio streams.
|
||||||
|
|
@ -159,33 +159,33 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
* for more details.
|
* for more details.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Corresponding method: None
|
* <li>Corresponding method: None
|
||||||
* <li>Default: {@code R.layout.exo_styled_player_view}
|
* <li>Default: {@code R.layout.exo_player_view}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li><b>{@code controller_layout_id}</b> - Specifies the id of the layout resource to be
|
* <li><b>{@code controller_layout_id}</b> - Specifies the id of the layout resource to be
|
||||||
* inflated by the child {@link StyledPlayerControlView}. See below for more details.
|
* inflated by the child {@link PlayerControlView}. See below for more details.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Corresponding method: None
|
* <li>Corresponding method: None
|
||||||
* <li>Default: {@code R.layout.exo_styled_player_control_view}
|
* <li>Default: {@code R.layout.exo_player_control_view}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li>All attributes that can be set on {@link StyledPlayerControlView} and {@link
|
* <li>All attributes that can be set on {@link PlayerControlView} and {@link DefaultTimeBar} can
|
||||||
* DefaultTimeBar} can also be set on a StyledPlayerView, and will be propagated to the
|
* also be set on a PlayerView, and will be propagated to the inflated {@link
|
||||||
* inflated {@link StyledPlayerControlView} unless the layout is overridden to specify a
|
* PlayerControlView} unless the layout is overridden to specify a custom {@code
|
||||||
* custom {@code exo_controller} (see below).
|
* exo_controller} (see below).
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <h2>Overriding drawables</h2>
|
* <h2>Overriding drawables</h2>
|
||||||
*
|
*
|
||||||
* The drawables used by {@link StyledPlayerControlView} (with its default layout file) can be
|
* The drawables used by {@link PlayerControlView} (with its default layout file) can be overridden
|
||||||
* overridden by drawables with the same names defined in your application. See the {@link
|
* by drawables with the same names defined in your application. See the {@link PlayerControlView}
|
||||||
* StyledPlayerControlView} documentation for a list of drawables that can be overridden.
|
* documentation for a list of drawables that can be overridden.
|
||||||
*
|
*
|
||||||
* <h2>Overriding the layout file</h2>
|
* <h2>Overriding the layout file</h2>
|
||||||
*
|
*
|
||||||
* To customize the layout of StyledPlayerView throughout your app, or just for certain
|
* To customize the layout of PlayerView throughout your app, or just for certain configurations,
|
||||||
* configurations, you can define {@code exo_styled_player_view.xml} layout files in your
|
* you can define {@code exo_player_view.xml} layout files in your application {@code res/layout*}
|
||||||
* application {@code res/layout*} directories. These layouts will override the one provided by the
|
* directories. These layouts will override the one provided by the library, and will be inflated
|
||||||
* library, and will be inflated for use by StyledPlayerView. The view identifies and binds its
|
* for use by PlayerView. The view identifies and binds its children by looking for the following
|
||||||
* children by looking for the following ids:
|
* ids:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><b>{@code exo_content_frame}</b> - A frame whose aspect ratio is resized based on the video
|
* <li><b>{@code exo_content_frame}</b> - A frame whose aspect ratio is resized based on the video
|
||||||
|
|
@ -219,17 +219,17 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
* <li>Type: {@link TextView}
|
* <li>Type: {@link TextView}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li><b>{@code exo_controller_placeholder}</b> - A placeholder that's replaced with the inflated
|
* <li><b>{@code exo_controller_placeholder}</b> - A placeholder that's replaced with the inflated
|
||||||
* {@link StyledPlayerControlView}. Ignored if an {@code exo_controller} view exists.
|
* {@link PlayerControlView}. Ignored if an {@code exo_controller} view exists.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Type: {@link View}
|
* <li>Type: {@link View}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li><b>{@code exo_controller}</b> - An already inflated {@link StyledPlayerControlView}. Allows
|
* <li><b>{@code exo_controller}</b> - An already inflated {@link PlayerControlView}. Allows use
|
||||||
* use of a custom extension of {@link StyledPlayerControlView}. {@link
|
* of a custom extension of {@link PlayerControlView}. {@link PlayerControlView} and {@link
|
||||||
* StyledPlayerControlView} and {@link DefaultTimeBar} attributes set on the StyledPlayerView
|
* DefaultTimeBar} attributes set on the PlayerView will not be automatically propagated
|
||||||
* will not be automatically propagated through to this instance. If a view exists with this
|
* through to this instance. If a view exists with this id, any {@code
|
||||||
* id, any {@code exo_controller_placeholder} view will be ignored.
|
* exo_controller_placeholder} view will be ignored.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Type: {@link StyledPlayerControlView}
|
* <li>Type: {@link PlayerControlView}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li><b>{@code exo_ad_overlay}</b> - A {@link FrameLayout} positioned on top of the player which
|
* <li><b>{@code exo_ad_overlay}</b> - A {@link FrameLayout} positioned on top of the player which
|
||||||
* is used to show ad UI (if applicable).
|
* is used to show ad UI (if applicable).
|
||||||
|
|
@ -248,14 +248,14 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
*
|
*
|
||||||
* <h2>Specifying a custom layout file</h2>
|
* <h2>Specifying a custom layout file</h2>
|
||||||
*
|
*
|
||||||
* Defining your own {@code exo_styled_player_view.xml} is useful to customize the layout of
|
* Defining your own {@code exo_player_view.xml} is useful to customize the layout of PlayerView
|
||||||
* StyledPlayerView throughout your application. It's also possible to customize the layout for a
|
* throughout your application. It's also possible to customize the layout for a single instance in
|
||||||
* single instance in a layout file. This is achieved by setting the {@code player_layout_id}
|
* a layout file. This is achieved by setting the {@code player_layout_id} attribute on a
|
||||||
* attribute on a StyledPlayerView. This will cause the specified layout to be inflated instead of
|
* PlayerView. This will cause the specified layout to be inflated instead of {@code
|
||||||
* {@code exo_styled_player_view.xml} for only the instance on which the attribute is set.
|
* exo_player_view.xml} for only the instance on which the attribute is set.
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines when the buffering view is shown. One of {@link #SHOW_BUFFERING_NEVER}, {@link
|
* Determines when the buffering view is shown. One of {@link #SHOW_BUFFERING_NEVER}, {@link
|
||||||
|
|
@ -293,13 +293,13 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
@Nullable private final SubtitleView subtitleView;
|
@Nullable private final SubtitleView subtitleView;
|
||||||
@Nullable private final View bufferingView;
|
@Nullable private final View bufferingView;
|
||||||
@Nullable private final TextView errorMessageView;
|
@Nullable private final TextView errorMessageView;
|
||||||
@Nullable private final StyledPlayerControlView controller;
|
@Nullable private final PlayerControlView controller;
|
||||||
@Nullable private final FrameLayout adOverlayFrameLayout;
|
@Nullable private final FrameLayout adOverlayFrameLayout;
|
||||||
@Nullable private final FrameLayout overlayFrameLayout;
|
@Nullable private final FrameLayout overlayFrameLayout;
|
||||||
|
|
||||||
@Nullable private Player player;
|
@Nullable private Player player;
|
||||||
private boolean useController;
|
private boolean useController;
|
||||||
@Nullable private StyledPlayerControlView.VisibilityListener controllerVisibilityListener;
|
@Nullable private PlayerControlView.VisibilityListener controllerVisibilityListener;
|
||||||
private boolean useArtwork;
|
private boolean useArtwork;
|
||||||
@Nullable private Drawable defaultArtwork;
|
@Nullable private Drawable defaultArtwork;
|
||||||
private @ShowBuffering int showBuffering;
|
private @ShowBuffering int showBuffering;
|
||||||
|
|
@ -315,16 +315,16 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
private static final int PICTURE_TYPE_FRONT_COVER = 3;
|
private static final int PICTURE_TYPE_FRONT_COVER = 3;
|
||||||
private static final int PICTURE_TYPE_NOT_SET = -1;
|
private static final int PICTURE_TYPE_NOT_SET = -1;
|
||||||
|
|
||||||
public StyledPlayerView(Context context) {
|
public PlayerView(Context context) {
|
||||||
this(context, /* attrs= */ null);
|
this(context, /* attrs= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StyledPlayerView(Context context, @Nullable AttributeSet attrs) {
|
public PlayerView(Context context, @Nullable AttributeSet attrs) {
|
||||||
this(context, attrs, /* defStyleAttr= */ 0);
|
this(context, attrs, /* defStyleAttr= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"nullness:argument", "nullness:method.invocation"})
|
@SuppressWarnings({"nullness:argument", "nullness:method.invocation"})
|
||||||
public StyledPlayerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
public PlayerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
componentListener = new ComponentListener();
|
componentListener = new ComponentListener();
|
||||||
|
|
@ -353,13 +353,13 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
|
|
||||||
boolean shutterColorSet = false;
|
boolean shutterColorSet = false;
|
||||||
int shutterColor = 0;
|
int shutterColor = 0;
|
||||||
int playerLayoutId = R.layout.exo_styled_player_view;
|
int playerLayoutId = R.layout.exo_player_view;
|
||||||
boolean useArtwork = true;
|
boolean useArtwork = true;
|
||||||
int defaultArtworkId = 0;
|
int defaultArtworkId = 0;
|
||||||
boolean useController = true;
|
boolean useController = true;
|
||||||
int surfaceType = SURFACE_TYPE_SURFACE_VIEW;
|
int surfaceType = SURFACE_TYPE_SURFACE_VIEW;
|
||||||
int resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
int resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
||||||
int controllerShowTimeoutMs = StyledPlayerControlView.DEFAULT_SHOW_TIMEOUT_MS;
|
int controllerShowTimeoutMs = PlayerControlView.DEFAULT_SHOW_TIMEOUT_MS;
|
||||||
boolean controllerHideOnTouch = true;
|
boolean controllerHideOnTouch = true;
|
||||||
boolean controllerAutoShow = true;
|
boolean controllerAutoShow = true;
|
||||||
boolean controllerHideDuringAds = true;
|
boolean controllerHideDuringAds = true;
|
||||||
|
|
@ -369,32 +369,28 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
context
|
context
|
||||||
.getTheme()
|
.getTheme()
|
||||||
.obtainStyledAttributes(
|
.obtainStyledAttributes(
|
||||||
attrs, R.styleable.StyledPlayerView, defStyleAttr, /* defStyleRes= */ 0);
|
attrs, R.styleable.PlayerView, defStyleAttr, /* defStyleRes= */ 0);
|
||||||
try {
|
try {
|
||||||
shutterColorSet = a.hasValue(R.styleable.StyledPlayerView_shutter_background_color);
|
shutterColorSet = a.hasValue(R.styleable.PlayerView_shutter_background_color);
|
||||||
shutterColor =
|
shutterColor = a.getColor(R.styleable.PlayerView_shutter_background_color, shutterColor);
|
||||||
a.getColor(R.styleable.StyledPlayerView_shutter_background_color, shutterColor);
|
playerLayoutId = a.getResourceId(R.styleable.PlayerView_player_layout_id, playerLayoutId);
|
||||||
playerLayoutId =
|
useArtwork = a.getBoolean(R.styleable.PlayerView_use_artwork, useArtwork);
|
||||||
a.getResourceId(R.styleable.StyledPlayerView_player_layout_id, playerLayoutId);
|
|
||||||
useArtwork = a.getBoolean(R.styleable.StyledPlayerView_use_artwork, useArtwork);
|
|
||||||
defaultArtworkId =
|
defaultArtworkId =
|
||||||
a.getResourceId(R.styleable.StyledPlayerView_default_artwork, defaultArtworkId);
|
a.getResourceId(R.styleable.PlayerView_default_artwork, defaultArtworkId);
|
||||||
useController = a.getBoolean(R.styleable.StyledPlayerView_use_controller, useController);
|
useController = a.getBoolean(R.styleable.PlayerView_use_controller, useController);
|
||||||
surfaceType = a.getInt(R.styleable.StyledPlayerView_surface_type, surfaceType);
|
surfaceType = a.getInt(R.styleable.PlayerView_surface_type, surfaceType);
|
||||||
resizeMode = a.getInt(R.styleable.StyledPlayerView_resize_mode, resizeMode);
|
resizeMode = a.getInt(R.styleable.PlayerView_resize_mode, resizeMode);
|
||||||
controllerShowTimeoutMs =
|
controllerShowTimeoutMs =
|
||||||
a.getInt(R.styleable.StyledPlayerView_show_timeout, controllerShowTimeoutMs);
|
a.getInt(R.styleable.PlayerView_show_timeout, controllerShowTimeoutMs);
|
||||||
controllerHideOnTouch =
|
controllerHideOnTouch =
|
||||||
a.getBoolean(R.styleable.StyledPlayerView_hide_on_touch, controllerHideOnTouch);
|
a.getBoolean(R.styleable.PlayerView_hide_on_touch, controllerHideOnTouch);
|
||||||
controllerAutoShow =
|
controllerAutoShow = a.getBoolean(R.styleable.PlayerView_auto_show, controllerAutoShow);
|
||||||
a.getBoolean(R.styleable.StyledPlayerView_auto_show, controllerAutoShow);
|
showBuffering = a.getInteger(R.styleable.PlayerView_show_buffering, showBuffering);
|
||||||
showBuffering = a.getInteger(R.styleable.StyledPlayerView_show_buffering, showBuffering);
|
|
||||||
keepContentOnPlayerReset =
|
keepContentOnPlayerReset =
|
||||||
a.getBoolean(
|
a.getBoolean(
|
||||||
R.styleable.StyledPlayerView_keep_content_on_player_reset,
|
R.styleable.PlayerView_keep_content_on_player_reset, keepContentOnPlayerReset);
|
||||||
keepContentOnPlayerReset);
|
|
||||||
controllerHideDuringAds =
|
controllerHideDuringAds =
|
||||||
a.getBoolean(R.styleable.StyledPlayerView_hide_during_ads, controllerHideDuringAds);
|
a.getBoolean(R.styleable.PlayerView_hide_during_ads, controllerHideDuringAds);
|
||||||
} finally {
|
} finally {
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
@ -451,9 +447,9 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
surfaceView.setLayoutParams(params);
|
surfaceView.setLayoutParams(params);
|
||||||
// We don't want surfaceView to be clickable separately to the StyledPlayerView itself, but we
|
// We don't want surfaceView to be clickable separately to the PlayerView itself, but we
|
||||||
// do want to register as an OnClickListener so that surfaceView implementations can propagate
|
// do want to register as an OnClickListener so that surfaceView implementations can propagate
|
||||||
// click events up to the StyledPlayerView by calling their own performClick method.
|
// click events up to the PlayerView by calling their own performClick method.
|
||||||
surfaceView.setOnClickListener(componentListener);
|
surfaceView.setOnClickListener(componentListener);
|
||||||
surfaceView.setClickable(false);
|
surfaceView.setClickable(false);
|
||||||
contentFrame.addView(surfaceView, 0);
|
contentFrame.addView(surfaceView, 0);
|
||||||
|
|
@ -496,14 +492,14 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Playback control view.
|
// Playback control view.
|
||||||
StyledPlayerControlView customController = findViewById(R.id.exo_controller);
|
PlayerControlView customController = findViewById(R.id.exo_controller);
|
||||||
View controllerPlaceholder = findViewById(R.id.exo_controller_placeholder);
|
View controllerPlaceholder = findViewById(R.id.exo_controller_placeholder);
|
||||||
if (customController != null) {
|
if (customController != null) {
|
||||||
this.controller = customController;
|
this.controller = customController;
|
||||||
} else if (controllerPlaceholder != null) {
|
} else if (controllerPlaceholder != null) {
|
||||||
// Propagate attrs as playbackAttrs so that StyledPlayerControlView's custom attributes are
|
// Propagate attrs as playbackAttrs so that StyledPlayerControlView's custom attributes are
|
||||||
// transferred, but standard attributes (e.g. background) are not.
|
// transferred, but standard attributes (e.g. background) are not.
|
||||||
this.controller = new StyledPlayerControlView(context, null, 0, attrs);
|
this.controller = new PlayerControlView(context, null, 0, attrs);
|
||||||
controller.setId(R.id.exo_controller);
|
controller.setId(R.id.exo_controller);
|
||||||
controller.setLayoutParams(controllerPlaceholder.getLayoutParams());
|
controller.setLayoutParams(controllerPlaceholder.getLayoutParams());
|
||||||
ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent());
|
ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent());
|
||||||
|
|
@ -533,9 +529,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
* @param newPlayerView The new view to attach to the player.
|
* @param newPlayerView The new view to attach to the player.
|
||||||
*/
|
*/
|
||||||
public static void switchTargetView(
|
public static void switchTargetView(
|
||||||
Player player,
|
Player player, @Nullable PlayerView oldPlayerView, @Nullable PlayerView newPlayerView) {
|
||||||
@Nullable StyledPlayerView oldPlayerView,
|
|
||||||
@Nullable StyledPlayerView newPlayerView) {
|
|
||||||
if (oldPlayerView == newPlayerView) {
|
if (oldPlayerView == newPlayerView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -561,10 +555,10 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
* Sets the {@link Player} to use.
|
* Sets the {@link Player} to use.
|
||||||
*
|
*
|
||||||
* <p>To transition a {@link Player} from targeting one view to another, it's recommended to use
|
* <p>To transition a {@link Player} from targeting one view to another, it's recommended to use
|
||||||
* {@link #switchTargetView(Player, StyledPlayerView, StyledPlayerView)} rather than this method.
|
* {@link #switchTargetView(Player, PlayerView, PlayerView)} rather than this method. If you do
|
||||||
* If you do wish to use this method directly, be sure to attach the player to the new view
|
* wish to use this method directly, be sure to attach the player to the new view <em>before</em>
|
||||||
* <em>before</em> calling {@code setPlayer(null)} to detach it from the old one. This ordering is
|
* calling {@code setPlayer(null)} to detach it from the old one. This ordering is significantly
|
||||||
* significantly more efficient and may allow for more seamless transitions.
|
* more efficient and may allow for more seamless transitions.
|
||||||
*
|
*
|
||||||
* @param player The {@link Player} to use, or {@code null} to detach the current player. Only
|
* @param player The {@link Player} to use, or {@code null} to detach the current player. Only
|
||||||
* players which are accessed on the main thread are supported ({@code
|
* players which are accessed on the main thread are supported ({@code
|
||||||
|
|
@ -913,13 +907,13 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link StyledPlayerControlView.VisibilityListener}.
|
* Sets the {@link PlayerControlView.VisibilityListener}.
|
||||||
*
|
*
|
||||||
* @param listener The listener to be notified about visibility changes, or null to remove the
|
* @param listener The listener to be notified about visibility changes, or null to remove the
|
||||||
* current listener.
|
* current listener.
|
||||||
*/
|
*/
|
||||||
public void setControllerVisibilityListener(
|
public void setControllerVisibilityListener(
|
||||||
@Nullable StyledPlayerControlView.VisibilityListener listener) {
|
@Nullable PlayerControlView.VisibilityListener listener) {
|
||||||
Assertions.checkStateNotNull(controller);
|
Assertions.checkStateNotNull(controller);
|
||||||
if (this.controllerVisibilityListener == listener) {
|
if (this.controllerVisibilityListener == listener) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -934,13 +928,13 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link StyledPlayerControlView.OnFullScreenModeChangedListener}.
|
* Sets the {@link PlayerControlView.OnFullScreenModeChangedListener}.
|
||||||
*
|
*
|
||||||
* @param listener The listener to be notified when the fullscreen button is clicked, or null to
|
* @param listener The listener to be notified when the fullscreen button is clicked, or null to
|
||||||
* remove the current listener and hide the fullscreen button.
|
* remove the current listener and hide the fullscreen button.
|
||||||
*/
|
*/
|
||||||
public void setControllerOnFullScreenModeChangedListener(
|
public void setControllerOnFullScreenModeChangedListener(
|
||||||
@Nullable StyledPlayerControlView.OnFullScreenModeChangedListener listener) {
|
@Nullable PlayerControlView.OnFullScreenModeChangedListener listener) {
|
||||||
Assertions.checkStateNotNull(controller);
|
Assertions.checkStateNotNull(controller);
|
||||||
controller.setOnFullScreenModeChangedListener(listener);
|
controller.setOnFullScreenModeChangedListener(listener);
|
||||||
}
|
}
|
||||||
|
|
@ -1496,7 +1490,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
implements Player.Listener,
|
implements Player.Listener,
|
||||||
OnLayoutChangeListener,
|
OnLayoutChangeListener,
|
||||||
OnClickListener,
|
OnClickListener,
|
||||||
StyledPlayerControlView.VisibilityListener {
|
PlayerControlView.VisibilityListener {
|
||||||
|
|
||||||
private final Period period;
|
private final Period period;
|
||||||
private @Nullable Object lastPeriodUidWithTracks;
|
private @Nullable Object lastPeriodUidWithTracks;
|
||||||
|
|
@ -1531,7 +1525,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
// Suppress the update if transitioning to an unprepared period within the same window. This
|
// Suppress the update if transitioning to an unprepared period within the same window. This
|
||||||
// is necessary to avoid closing the shutter when such a transition occurs. See:
|
// is necessary to avoid closing the shutter when such a transition occurs. See:
|
||||||
// https://github.com/google/ExoPlayer/issues/5507.
|
// https://github.com/google/ExoPlayer/issues/5507.
|
||||||
Player player = checkNotNull(StyledPlayerView.this.player);
|
Player player = checkNotNull(PlayerView.this.player);
|
||||||
Timeline timeline = player.getCurrentTimeline();
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
if (timeline.isEmpty()) {
|
if (timeline.isEmpty()) {
|
||||||
lastPeriodUidWithTracks = null;
|
lastPeriodUidWithTracks = null;
|
||||||
|
|
@ -136,12 +136,12 @@
|
||||||
<ImageButton android:id="@id/exo_prev"
|
<ImageButton android:id="@id/exo_prev"
|
||||||
style="@style/ExoStyledControls.Button.Center.Previous"/>
|
style="@style/ExoStyledControls.Button.Center.Previous"/>
|
||||||
|
|
||||||
<include layout="@layout/exo_styled_player_control_rewind_button" />
|
<include layout="@layout/exo_player_control_rewind_button" />
|
||||||
|
|
||||||
<ImageButton android:id="@id/exo_play_pause"
|
<ImageButton android:id="@id/exo_play_pause"
|
||||||
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
||||||
|
|
||||||
<include layout="@layout/exo_styled_player_control_ffwd_button" />
|
<include layout="@layout/exo_player_control_ffwd_button" />
|
||||||
|
|
||||||
<ImageButton android:id="@id/exo_next"
|
<ImageButton android:id="@id/exo_next"
|
||||||
style="@style/ExoStyledControls.Button.Center.Next"/>
|
style="@style/ExoStyledControls.Button.Center.Next"/>
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<enum name="zoom" value="4"/>
|
<enum name="zoom" value="4"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<!-- Must be kept in sync with LegacyPlayerView and StyledPlayerView -->
|
<!-- Must be kept in sync with LegacyPlayerView and PlayerView -->
|
||||||
<attr name="surface_type" format="enum">
|
<attr name="surface_type" format="enum">
|
||||||
<enum name="none" value="0"/>
|
<enum name="none" value="0"/>
|
||||||
<enum name="surface_view" value="1"/>
|
<enum name="surface_view" value="1"/>
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
<flag name="all" value="2"/>
|
<flag name="all" value="2"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<!-- LegacyPlayerView and StyledPlayerView attributes -->
|
<!-- LegacyPlayerView and PlayerView attributes -->
|
||||||
<attr name="use_artwork" format="boolean"/>
|
<attr name="use_artwork" format="boolean"/>
|
||||||
<attr name="shutter_background_color" format="color"/>
|
<attr name="shutter_background_color" format="color"/>
|
||||||
<attr name="default_artwork" format="reference"/>
|
<attr name="default_artwork" format="reference"/>
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
<attr name="keep_content_on_player_reset" format="boolean"/>
|
<attr name="keep_content_on_player_reset" format="boolean"/>
|
||||||
<attr name="player_layout_id" format="reference"/>
|
<attr name="player_layout_id" format="reference"/>
|
||||||
|
|
||||||
<!-- LegacyPlayerControlView and StyledPlayerControlView attributes -->
|
<!-- LegacyPlayerControlView and PlayerControlView attributes -->
|
||||||
<attr name="show_timeout" format="integer"/>
|
<attr name="show_timeout" format="integer"/>
|
||||||
<attr name="show_rewind_button" format="boolean"/>
|
<attr name="show_rewind_button" format="boolean"/>
|
||||||
<attr name="show_fastforward_button" format="boolean"/>
|
<attr name="show_fastforward_button" format="boolean"/>
|
||||||
|
|
@ -91,7 +91,7 @@
|
||||||
<attr name="ad_marker_color" format="color"/>
|
<attr name="ad_marker_color" format="color"/>
|
||||||
<attr name="played_ad_marker_color" format="color"/>
|
<attr name="played_ad_marker_color" format="color"/>
|
||||||
|
|
||||||
<declare-styleable name="StyledPlayerView">
|
<declare-styleable name="PlayerView">
|
||||||
<attr name="use_artwork"/>
|
<attr name="use_artwork"/>
|
||||||
<attr name="shutter_background_color"/>
|
<attr name="shutter_background_color"/>
|
||||||
<attr name="default_artwork"/>
|
<attr name="default_artwork"/>
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
<attr name="surface_type"/>
|
<attr name="surface_type"/>
|
||||||
<!-- AspectRatioFrameLayout attributes -->
|
<!-- AspectRatioFrameLayout attributes -->
|
||||||
<attr name="resize_mode"/>
|
<attr name="resize_mode"/>
|
||||||
<!-- StyledPlayerControlView attributes -->
|
<!-- PlayerControlView attributes -->
|
||||||
<attr name="show_timeout"/>
|
<attr name="show_timeout"/>
|
||||||
<attr name="repeat_toggle_modes"/>
|
<attr name="repeat_toggle_modes"/>
|
||||||
<attr name="show_shuffle_button"/>
|
<attr name="show_shuffle_button"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue