10
10
import android .view .ViewGroup ;
11
11
import android .widget .Toast ;
12
12
13
+ import androidx .annotation .NonNull ;
13
14
import androidx .annotation .Nullable ;
14
15
15
16
import com .google .android .exoplayer2 .C ;
16
- import com .google .android .exoplayer2 .ExoPlaybackException ;
17
+ import com .google .android .exoplayer2 .ExoPlayer ;
17
18
import com .google .android .exoplayer2 .PlaybackException ;
18
- import com .google .android .exoplayer2 .PlaybackParameters ;
19
19
import com .google .android .exoplayer2 .Player ;
20
- import com .google .android .exoplayer2 .SimpleExoPlayer ;
21
20
import com .google .android .exoplayer2 .source .ClippingMediaSource ;
22
21
import com .google .android .exoplayer2 .source .LoopingMediaSource ;
23
22
import com .google .android .exoplayer2 .source .MediaSource ;
24
- import com .google .android .exoplayer2 .source .TrackGroupArray ;
25
- import com .google .android .exoplayer2 .trackselection .TrackSelectionArray ;
26
- import com .google .android .exoplayer2 .video .VideoListener ;
23
+ import com .google .android .exoplayer2 .video .VideoSize ;
27
24
28
25
import org .drinkless .td .libcore .telegram .TdApi ;
29
26
import org .thunderdog .challegram .BaseActivity ;
47
44
* Author: default
48
45
*/
49
46
50
- public class VideoPlayerView implements Player .EventListener , CallManager .CurrentCallListener , Runnable , VideoListener {
47
+ public class VideoPlayerView implements Player .Listener , CallManager .CurrentCallListener , Runnable {
51
48
private static class SeekHandler extends Handler {
52
49
@ Override
53
50
public void handleMessage (Message msg ) {
@@ -58,7 +55,7 @@ public void handleMessage (Message msg) {
58
55
private final SeekHandler seekHandler ;
59
56
// private final TrackSelector selector;
60
57
// private final LoadControl loadControl;
61
- private @ Nullable SimpleExoPlayer player ;
58
+ private @ Nullable ExoPlayer player ;
62
59
private View targetView ;
63
60
64
61
private boolean noProgressUpdates ;
@@ -109,19 +106,6 @@ public void setNoProgressUpdates (boolean noProgressUpdates) {
109
106
110
107
// ExoPlayer stuff
111
108
112
- @ Override
113
- public void onPlaybackParametersChanged (PlaybackParameters playbackParameters ) {
114
-
115
- }
116
-
117
- @ Override
118
- public void onTracksChanged (TrackGroupArray trackGroups , TrackSelectionArray trackSelections ) {
119
-
120
- }
121
-
122
- @ Override
123
- public void onRepeatModeChanged (int mode ) { }
124
-
125
109
private @ Nullable MediaItem currentItem ;
126
110
127
111
public void setVideo (@ Nullable MediaItem mediaItem ) {
@@ -187,7 +171,6 @@ public void setVideo (@Nullable MediaItem mediaItem) {
187
171
if (player == null ) {
188
172
this .player = U .newExoPlayer (context , preferExtensions );
189
173
this .player .addListener (this );
190
- this .player .addVideoListener (this );
191
174
checkMuted ();
192
175
if (targetView instanceof SurfaceView ) {
193
176
this .player .setVideoSurfaceView ((SurfaceView ) targetView );
@@ -256,10 +239,10 @@ private void setDataSource (MediaSource mediaSource) {
256
239
}
257
240
258
241
@ Override
259
- public void onVideoSizeChanged (int width , int height , int unappliedRotationDegrees , float pixelWidthHeightRatio ) {
260
- if (player == null || currentItem == null || width == 0 || height == 0 )
242
+ public void onVideoSizeChanged (@ NonNull VideoSize videoSize ) {
243
+ if (player == null || currentItem == null || videoSize . width == 0 || videoSize . height == 0 )
261
244
return ;
262
- if (currentItem .setDimensions (width , height ) && targetView != null ) {
245
+ if (currentItem .setDimensions (videoSize . width , videoSize . height ) && targetView != null ) {
263
246
targetView .requestLayout ();
264
247
}
265
248
}
@@ -355,12 +338,7 @@ public void setBoundCell (MediaCellView boundCell) {
355
338
// ExoPlayer listener
356
339
357
340
@ Override
358
- public void onLoadingChanged (boolean isLoading ) {
359
-
360
- }
361
-
362
- @ Override
363
- public void onPlayerStateChanged (boolean playWhenReady , int playbackState ) {
341
+ public void onPlaybackStateChanged (@ Player .State int playbackState ) {
364
342
if (callback != null && playbackState == Player .STATE_READY ) {
365
343
callback .onPlayReady ();
366
344
}
0 commit comments