Skip to content

Commit 1391b7c

Browse files
committed
Remove references to Player(Control)View from the dev guide
Remove most of the customisation documentation, since StyledPlayerView isn't really designed to be customised as deeply as PlayerView. Also remove most documentation around StyledPlayerControlView, especially as a standalone controller class - since it doesn't work well for this use-case. #minor-release PiperOrigin-RevId: 426090762
1 parent 7463011 commit 1391b7c

File tree

7 files changed

+58
-365
lines changed

7 files changed

+58
-365
lines changed

docs/ad-insertion.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ Internally, `DefaultMediaSourceFactory` will wrap the content media source in an
6464
`AdsLoader.Provider` and use it to insert ads as defined by the media item's ad
6565
tag.
6666

67-
ExoPlayer's `StyledPlayerView` and `PlayerView` UI components both
68-
implement `AdViewProvider`. The IMA extension provides an easy to use
69-
`AdsLoader`, as described below.
67+
ExoPlayer's `StyledPlayerView` implements `AdViewProvider`. The IMA extension
68+
provides an easy to use `AdsLoader`, as described below.
7069

7170
### Playlists with ads ###
7271

@@ -123,11 +122,11 @@ VAST/VMAP ad tags in the sample list.
123122

124123
#### UI considerations ####
125124

126-
`StyledPlayerView` and `PlayerView` hide controls during playback of ads
127-
by default, but apps can toggle this behavior by calling
128-
`setControllerHideDuringAds`, which is defined on both views. The IMA SDK will
129-
show additional views on top of the player while an ad is playing (e.g., a 'more
130-
info' link and a skip button, if applicable).
125+
`StyledPlayerView` hides its transport controls during playback of ads by
126+
default, but apps can toggle this behavior by calling
127+
`setControllerHideDuringAds`. The IMA SDK will show additional views on top of
128+
the player while an ad is playing (e.g., a 'more info' link and a skip button,
129+
if applicable).
131130

132131
Since advertisers expect a consistent experience across apps, the IMA SDK does
133132
not allow customization of the views that it shows while an ad is playing. It is
@@ -139,9 +138,9 @@ The IMA SDK may report whether ads are obscured by application provided views
139138
rendered on top of the player. Apps that need to overlay views that are
140139
essential for controlling playback must register them with the IMA SDK so that
141140
they can be omitted from viewability calculations. When using `StyledPlayerView`
142-
or `PlayerView` as the `AdViewProvider`, they will automatically register
143-
their control overlays. Apps that use a custom player UI must register overlay
144-
views by returning them from `AdViewProvider.getAdOverlayInfos`.
141+
as the `AdViewProvider`, it will automatically register its control overlays.
142+
Apps that use a custom player UI must register overlay views by returning them
143+
from `AdViewProvider.getAdOverlayInfos`.
145144

146145
For more information about overlay views, see
147146
[Open Measurement in the IMA SDK][].

docs/hls.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,5 @@ The following guidelines apply specifically for live streams:
130130

131131
[HlsMediaSource]: {{ site.exo_sdk }}/source/hls/HlsMediaSource.html
132132
[HTTP Live Streaming]: https://tools.ietf.org/html/rfc8216
133-
[UI components]: {{ site.baseurl }}/ui-components.html
134133
[Customization page]: {{ site.baseurl }}/customization.html
135134
[Medium post about HLS playback in ExoPlayer]: https://medium.com/google-exoplayer/hls-playback-in-exoplayer-a33959a47be7

docs/ui-components.md

Lines changed: 34 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,20 @@ implementation 'com.google.android.exoplayer:exoplayer-ui:2.X.X'
1212
~~~
1313
{: .language-gradle}
1414

15-
The most important components are `StyledPlayerControlView`, `StyledPlayerView`,
16-
`PlayerControlView` and `PlayerView`. The styled variants provide a more
17-
polished user experience, however are harder to customize.
15+
The most important component is `StyledPlayerView`, a view for media
16+
playbacks. It displays video, subtitles and album art during playback, as
17+
well as playback controls.
1818

19-
* [`StyledPlayerControlView`][] and [`PlayerControlView`][] are views for
20-
controlling playbacks. They display standard playback controls including a
21-
play/pause button, fast-forward and rewind buttons, and a seek bar.
22-
* [`StyledPlayerView`][] and [`PlayerView`][] are high level views for
23-
playbacks. They display video, subtitles and album art during playback, as
24-
well as playback controls using a `StyledPlayerControlView` or
25-
`PlayerControlView` respectively.
19+
`StyledPlayerView` has a `setPlayer` method for attaching and detaching (by
20+
passing `null`) player instances.
2621

27-
All four views have a `setPlayer` method for attaching and detaching (by passing
28-
`null`) player instances.
22+
## `StyledPlayerView` ##
2923

30-
## Player views ##
31-
32-
`StyledPlayerView` and `PlayerView` can be used for both video and audio
33-
playbacks. They render video and subtitles in the case of video playback, and
34-
can display artwork included as metadata in audio files. You can include them in
35-
your layout files like any other UI component. For example, a `StyledPlayerView`
36-
can be included with the following XML:
24+
`StyledPlayerView` can be used for both video and audio playbacks. It renders
25+
video and subtitles in the case of video playback, and can display artwork
26+
included as metadata in audio files. You can include it in your layout files
27+
like any other UI component. For example, a `StyledPlayerView` can be included
28+
with the following XML:
3729

3830
~~~
3931
<com.google.android.exoplayer2.ui.StyledPlayerView
@@ -50,7 +42,7 @@ attributes. These attributes can be used to customize the view's behavior, as
5042
well as its look and feel. Most of these attributes have corresponding setter
5143
methods, which can be used to customize the view at runtime. The
5244
[`StyledPlayerView`][] Javadoc lists these attributes and setter methods in
53-
more detail. [`PlayerView`][] defines similar attributes.
45+
more detail.
5446

5547
Once the view is declared in the layout file, it can be looked up in the
5648
`onCreate` method of the activity:
@@ -82,13 +74,13 @@ player.prepare();
8274

8375
### Choosing a surface type ###
8476

85-
The `surface_type` attribute of `StyledPlayerView` and `PlayerView` lets you set
86-
the type of surface used for video playback. Besides the values
87-
`spherical_gl_surface_view` (which is a special value for spherical video
88-
playback) and `video_decoder_gl_surface_view` (which is for video rendering
89-
using extension renderers), the allowed values are `surface_view`,
90-
`texture_view` and `none`. If the view is for audio playback only, `none` should
91-
be used to avoid having to create a surface, since doing so can be expensive.
77+
The `surface_type` attribute of `StyledPlayerView` lets you set the type of
78+
surface used for video playback. Besides the values `spherical_gl_surface_view`
79+
(which is a special value for spherical video playback) and
80+
`video_decoder_gl_surface_view` (which is for video rendering using extension
81+
renderers), the allowed values are `surface_view`, `texture_view` and `none`. If
82+
the view is for audio playback only, `none` should be used to avoid having to
83+
create a surface, since doing so can be expensive.
9284

9385
If the view is for regular video playback then `surface_view` or `texture_view`
9486
should be used. `SurfaceView` has a number of benefits over `TextureView` for
@@ -125,132 +117,29 @@ current display mode) can be queried using [`Util.getCurrentDisplayModeSize`][].
125117
The UI layer resolution can be queried using Android's [`Display.getSize`] API.
126118
{:.info}
127119

128-
## Player control views ##
129-
130-
When using `StyledPlayerView`, a `StyledPlayerControlView` is used internally to
131-
provide playback controls. When using a `PlayerView`, a `PlayerControlView` is
132-
used internally.
133-
134-
For specific use cases `StyledPlayerControlView` and `PlayerControlView` can
135-
also be used as standalone components. They can be included in your layout file
136-
as normal. For example:
137-
138-
~~~
139-
<com.google.android.exoplayer2.ui.StyledPlayerControlView
140-
android:id="@+id/player_control_view"
141-
android:layout_width="match_parent"
142-
android:layout_height="match_parent"/>
143-
~~~
144-
{: .language-xml}
145-
146-
The [`StyledPlayerControlView`][] and [`PlayerControlView`][] Javadoc list the
147-
the available attributes and setter methods for these components. Looking them
148-
up and attaching the player is similar to the example above:
149-
150-
~~~
151-
@Override
152-
protected void onCreate(Bundle savedInstanceState) {
153-
super.onCreate(savedInstanceState);
154-
// ...
155-
playerControlView = findViewById(R.id.player_control_view);
156-
}
157-
158-
private void initializePlayer() {
159-
// Instantiate the player.
160-
player = new ExoPlayer.Builder(context).build();
161-
// Attach player to the view.
162-
playerControlView.setPlayer(player);
163-
// Set the media item to be played.
164-
player.setMediaItem(mediaItem);
165-
// Prepare the player.
166-
player.prepare();
167-
}
168-
~~~
169-
{: .language-java}
170-
171-
## Customization ##
172-
173-
Where significant customization is required, we expect that app developers will
174-
implement their own UI components rather than using those provided by
175-
ExoPlayer's UI module. That said, the provided UI components do allow for
176-
customization by setting attributes (as described above), overriding drawables,
177-
overriding layout files, and by specifying custom layout files.
178-
179120
### Overriding drawables ###
180121

181-
The drawables used by `StyledPlayerControlView` and `PlayerControlView`
182-
(with their default layout files) can be overridden by drawables with the same
183-
names defined in your application. See the [`StyledPlayerControlView`][] and
184-
[`PlayerControlView`][] Javadoc for a list of drawables that can be overridden.
185-
Note that overriding these drawables will also affect the appearance of
186-
`PlayerView` and `StyledPlayerView`, since they use these views internally.
187-
188-
### Overriding layout files ###
189-
190-
All of the view components inflate their layouts from corresponding layout
191-
files, which are specified in their Javadoc. For example when a
192-
`PlayerControlView` is instantiated, it inflates its layout from
193-
`exo_player_control_view.xml`. To customize these layouts, an application
194-
can define layout files with the same names in its own `res/layout*`
195-
directories. These layout files will override the ones provided by the ExoPlayer
196-
library.
197-
198-
As an example, suppose we want our playback controls to consist of only a
199-
play/pause button positioned in the center of the view. We can achieve this by
200-
creating an `exo_player_control_view.xml` file in the application’s
201-
`res/layout` directory, containing:
202-
203-
~~~
204-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
205-
android:layout_width="match_parent"
206-
android:layout_height="match_parent">
207-
208-
<ImageButton android:id="@id/exo_play"
209-
android:layout_width="100dp"
210-
android:layout_height="100dp"
211-
android:layout_gravity="center"
212-
android:background="#CC000000"
213-
style="@style/ExoMediaButton.Play"/>
214-
215-
<ImageButton android:id="@id/exo_pause"
216-
android:layout_width="100dp"
217-
android:layout_height="100dp"
218-
android:layout_gravity="center"
219-
android:background="#CC000000"
220-
style="@style/ExoMediaButton.Pause"/>
221-
222-
</FrameLayout>
223-
~~~
224-
{: .language-xml}
225-
226-
The change in visual appearance compared to the standard controls is shown
227-
below.
228-
229-
{% include figure.html url="/images/overriding-layoutfiles.png" index="1" caption="Replacing the standard playback controls (left) with custom controls (right)" %}
122+
We don't guarantee that the customizations described in the following section
123+
will continue to work in future versions of the library. The resource IDs may
124+
change name, or some may be deleted entirely. This is indicated by the
125+
[resource IDs being marked 'private'][].
126+
{:.info}
230127

231-
### Custom layout files ###
128+
`StyledPlayerView` uses `StyledPlayerControlView` to display the playback
129+
controls and progress bar. The drawables used by `StyledPlayerControlView` can
130+
be overridden by drawables with the same names defined in your application. See
131+
the [`StyledPlayerControlView`][] Javadoc for a list of control drawables that
132+
can be overridden.
232133

233-
Overriding a layout file is an excellent solution for changing the layout across
234-
the whole of an application, but what if a custom layout is required only in a
235-
single place? To achieve this, first define a layout file as though overriding
236-
one of the default layouts, but this time giving it a different file name, for
237-
example `custom_controls.xml`. Second, use an attribute to indicate that this
238-
layout should be used when inflating the view. For example when using
239-
`PlayerView`, the layout inflated to provide the playback controls can be
240-
specified using the `controller_layout_id` attribute:
134+
## Further customization ##
241135

242-
~~~
243-
<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/player_view"
244-
android:layout_width="match_parent"
245-
android:layout_height="match_parent"
246-
app:controller_layout_id="@layout/custom_controls"/>
247-
~~~
248-
{: .language-xml}
136+
Where customization beyond that described above is required, we expect that app
137+
developers will implement their own UI components rather than use those provided
138+
by ExoPlayer's UI module.
249139

250-
[`PlayerView`]: {{ site.exo_sdk }}/ui/PlayerView.html
251-
[`PlayerControlView`]: {{ site.exo_sdk }}/ui/PlayerControlView.html
252140
[`StyledPlayerView`]: {{ site.exo_sdk }}/ui/StyledPlayerView.html
253141
[`StyledPlayerControlView`]: {{ site.exo_sdk }}/ui/StyledPlayerControlView.html
142+
[resource IDs being marked 'private']: https://developer.android.com/studio/projects/android-library#PrivateResources
254143
[`SDK_INT`]: {{ site.android_sdk }}/android/os/Build.VERSION.html#SDK_INT
255144
[`Util.getCurrentDisplayModeSize`]: {{ site.exo_sdk }}/util/Util.html#getCurrentDisplayModeSize(android.content.Context)
256145
[`Display.getSize`]: {{ site.android_sdk }}/android/view/Display.html#getSize(android.graphics.Point)

extensions/av1/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,20 @@ gets from the libgav1 decoder:
112112

113113
* GL rendering using GL shader for color space conversion
114114

115-
* If you are using `ExoPlayer` with `PlayerView` or `StyledPlayerView`,
116-
enable this option by setting `surface_type` of view to be
115+
* If you are using `ExoPlayer` with `StyledPlayerView`, enable this option
116+
by setting the `surface_type` of the view to be
117117
`video_decoder_gl_surface_view`.
118118
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a
119119
message of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
120120
`VideoDecoderOutputBufferRenderer` as its object.
121121
`VideoDecoderGLSurfaceView` is the concrete
122-
`VideoDecoderOutputBufferRenderer` implementation used by `PlayerView`
123-
and `StyledPlayerView`.
122+
`VideoDecoderOutputBufferRenderer` implementation used by
123+
`StyledPlayerView`.
124124

125125
* Native rendering using `ANativeWindow`
126126

127-
* If you are using `ExoPlayer` with `PlayerView` or `StyledPlayerView`,
128-
this option is enabled by default.
127+
* If you are using `ExoPlayer` with `StyledPlayerView`, this option is
128+
enabled by default.
129129
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a
130130
message of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
131131
`SurfaceView` as its object.

extensions/vp9/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,20 @@ gets from the libvpx decoder:
125125

126126
* GL rendering using GL shader for color space conversion
127127

128-
* If you are using `ExoPlayer` with `PlayerView` or `StyledPlayerView`,
129-
enable this option by setting `surface_type` of view to be
128+
* If you are using `ExoPlayer` with `StyledPlayerView`, enable this option
129+
by setting the `surface_type` of the view to be
130130
`video_decoder_gl_surface_view`.
131131
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message
132132
of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
133133
`VideoDecoderOutputBufferRenderer` as its object.
134134
`VideoDecoderGLSurfaceView` is the concrete
135-
`VideoDecoderOutputBufferRenderer` implementation used by `PlayerView`
136-
and `StyledPlayerView`.
135+
`VideoDecoderOutputBufferRenderer` implementation used by
136+
`StyledPlayerView`.
137137

138138
* Native rendering using `ANativeWindow`
139139

140-
* If you are using `ExoPlayer` with `PlayerView` or `StyledPlayerView`,
141-
this option is enabled by default.
140+
* If you are using `ExoPlayer` with `StyledPlayerView`, this option is
141+
enabled by default.
142142
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message
143143
of type `Renderer.MSG_SET_VIDEO_OUTPUT` with an instance of
144144
`SurfaceView` as its object.

0 commit comments

Comments
 (0)