9
9
import android .view .Surface ;
10
10
import com .google .android .exoplayer2 .C ;
11
11
import com .google .android .exoplayer2 .ExoPlaybackException ;
12
- import com .google .android .exoplayer2 .ExoPlayerFactory ;
13
12
import com .google .android .exoplayer2 .Format ;
13
+ import com .google .android .exoplayer2 .MediaItem ;
14
14
import com .google .android .exoplayer2 .PlaybackParameters ;
15
15
import com .google .android .exoplayer2 .Player ;
16
16
import com .google .android .exoplayer2 .Player .EventListener ;
17
17
import com .google .android .exoplayer2 .SimpleExoPlayer ;
18
18
import com .google .android .exoplayer2 .audio .AudioAttributes ;
19
- import com .google .android .exoplayer2 .extractor .DefaultExtractorsFactory ;
20
- import com .google .android .exoplayer2 .source .ExtractorMediaSource ;
21
19
import com .google .android .exoplayer2 .source .MediaSource ;
20
+ import com .google .android .exoplayer2 .source .ProgressiveMediaSource ;
22
21
import com .google .android .exoplayer2 .source .dash .DashMediaSource ;
23
22
import com .google .android .exoplayer2 .source .dash .DefaultDashChunkSource ;
24
23
import com .google .android .exoplayer2 .source .hls .HlsMediaSource ;
25
24
import com .google .android .exoplayer2 .source .smoothstreaming .DefaultSsChunkSource ;
26
25
import com .google .android .exoplayer2 .source .smoothstreaming .SsMediaSource ;
27
- import com .google .android .exoplayer2 .trackselection .DefaultTrackSelector ;
28
- import com .google .android .exoplayer2 .trackselection .TrackSelector ;
29
26
import com .google .android .exoplayer2 .upstream .DataSource ;
30
27
import com .google .android .exoplayer2 .upstream .DefaultDataSourceFactory ;
31
28
import com .google .android .exoplayer2 .upstream .DefaultHttpDataSource ;
@@ -70,8 +67,7 @@ final class VideoPlayer {
70
67
this .textureEntry = textureEntry ;
71
68
this .options = options ;
72
69
73
- TrackSelector trackSelector = new DefaultTrackSelector ();
74
- exoPlayer = ExoPlayerFactory .newSimpleInstance (context , trackSelector );
70
+ exoPlayer = new SimpleExoPlayer .Builder (context ).build ();
75
71
76
72
Uri uri = Uri .parse (dataSource );
77
73
@@ -89,7 +85,8 @@ final class VideoPlayer {
89
85
}
90
86
91
87
MediaSource mediaSource = buildMediaSource (uri , dataSourceFactory , formatHint , context );
92
- exoPlayer .prepare (mediaSource );
88
+ exoPlayer .setMediaSource (mediaSource );
89
+ exoPlayer .prepare ();
93
90
94
91
setupVideoPlayer (eventChannel , textureEntry );
95
92
}
@@ -131,18 +128,18 @@ private MediaSource buildMediaSource(
131
128
return new SsMediaSource .Factory (
132
129
new DefaultSsChunkSource .Factory (mediaDataSourceFactory ),
133
130
new DefaultDataSourceFactory (context , null , mediaDataSourceFactory ))
134
- .createMediaSource (uri );
131
+ .createMediaSource (MediaItem . fromUri ( uri ) );
135
132
case C .TYPE_DASH :
136
133
return new DashMediaSource .Factory (
137
134
new DefaultDashChunkSource .Factory (mediaDataSourceFactory ),
138
135
new DefaultDataSourceFactory (context , null , mediaDataSourceFactory ))
139
- .createMediaSource (uri );
136
+ .createMediaSource (MediaItem . fromUri ( uri ) );
140
137
case C .TYPE_HLS :
141
- return new HlsMediaSource .Factory (mediaDataSourceFactory ).createMediaSource (uri );
138
+ return new HlsMediaSource .Factory (mediaDataSourceFactory )
139
+ .createMediaSource (MediaItem .fromUri (uri ));
142
140
case C .TYPE_OTHER :
143
- return new ExtractorMediaSource .Factory (mediaDataSourceFactory )
144
- .setExtractorsFactory (new DefaultExtractorsFactory ())
145
- .createMediaSource (uri );
141
+ return new ProgressiveMediaSource .Factory (mediaDataSourceFactory )
142
+ .createMediaSource (MediaItem .fromUri (uri ));
146
143
default :
147
144
{
148
145
throw new IllegalStateException ("Unsupported type: " + type );
@@ -174,7 +171,7 @@ public void onCancel(Object o) {
174
171
new EventListener () {
175
172
176
173
@ Override
177
- public void onPlayerStateChanged ( final boolean playWhenReady , final int playbackState ) {
174
+ public void onPlaybackStateChanged ( final int playbackState ) {
178
175
if (playbackState == Player .STATE_BUFFERING ) {
179
176
sendBufferingUpdate ();
180
177
} else if (playbackState == Player .STATE_READY ) {
0 commit comments