99import android .view .Surface ;
1010import com .google .android .exoplayer2 .C ;
1111import com .google .android .exoplayer2 .ExoPlaybackException ;
12- import com .google .android .exoplayer2 .ExoPlayerFactory ;
1312import com .google .android .exoplayer2 .Format ;
13+ import com .google .android .exoplayer2 .MediaItem ;
1414import com .google .android .exoplayer2 .PlaybackParameters ;
1515import com .google .android .exoplayer2 .Player ;
1616import com .google .android .exoplayer2 .Player .EventListener ;
1717import com .google .android .exoplayer2 .SimpleExoPlayer ;
1818import com .google .android .exoplayer2 .audio .AudioAttributes ;
19- import com .google .android .exoplayer2 .extractor .DefaultExtractorsFactory ;
20- import com .google .android .exoplayer2 .source .ExtractorMediaSource ;
2119import com .google .android .exoplayer2 .source .MediaSource ;
20+ import com .google .android .exoplayer2 .source .ProgressiveMediaSource ;
2221import com .google .android .exoplayer2 .source .dash .DashMediaSource ;
2322import com .google .android .exoplayer2 .source .dash .DefaultDashChunkSource ;
2423import com .google .android .exoplayer2 .source .hls .HlsMediaSource ;
2524import com .google .android .exoplayer2 .source .smoothstreaming .DefaultSsChunkSource ;
2625import com .google .android .exoplayer2 .source .smoothstreaming .SsMediaSource ;
27- import com .google .android .exoplayer2 .trackselection .DefaultTrackSelector ;
28- import com .google .android .exoplayer2 .trackselection .TrackSelector ;
2926import com .google .android .exoplayer2 .upstream .DataSource ;
3027import com .google .android .exoplayer2 .upstream .DefaultDataSourceFactory ;
3128import com .google .android .exoplayer2 .upstream .DefaultHttpDataSource ;
@@ -70,8 +67,7 @@ final class VideoPlayer {
7067 this .textureEntry = textureEntry ;
7168 this .options = options ;
7269
73- TrackSelector trackSelector = new DefaultTrackSelector ();
74- exoPlayer = ExoPlayerFactory .newSimpleInstance (context , trackSelector );
70+ exoPlayer = new SimpleExoPlayer .Builder (context ).build ();
7571
7672 Uri uri = Uri .parse (dataSource );
7773
@@ -89,7 +85,8 @@ final class VideoPlayer {
8985 }
9086
9187 MediaSource mediaSource = buildMediaSource (uri , dataSourceFactory , formatHint , context );
92- exoPlayer .prepare (mediaSource );
88+ exoPlayer .setMediaSource (mediaSource );
89+ exoPlayer .prepare ();
9390
9491 setupVideoPlayer (eventChannel , textureEntry );
9592 }
@@ -131,18 +128,18 @@ private MediaSource buildMediaSource(
131128 return new SsMediaSource .Factory (
132129 new DefaultSsChunkSource .Factory (mediaDataSourceFactory ),
133130 new DefaultDataSourceFactory (context , null , mediaDataSourceFactory ))
134- .createMediaSource (uri );
131+ .createMediaSource (MediaItem . fromUri ( uri ) );
135132 case C .TYPE_DASH :
136133 return new DashMediaSource .Factory (
137134 new DefaultDashChunkSource .Factory (mediaDataSourceFactory ),
138135 new DefaultDataSourceFactory (context , null , mediaDataSourceFactory ))
139- .createMediaSource (uri );
136+ .createMediaSource (MediaItem . fromUri ( uri ) );
140137 case C .TYPE_HLS :
141- return new HlsMediaSource .Factory (mediaDataSourceFactory ).createMediaSource (uri );
138+ return new HlsMediaSource .Factory (mediaDataSourceFactory )
139+ .createMediaSource (MediaItem .fromUri (uri ));
142140 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 ));
146143 default :
147144 {
148145 throw new IllegalStateException ("Unsupported type: " + type );
@@ -174,7 +171,7 @@ public void onCancel(Object o) {
174171 new EventListener () {
175172
176173 @ Override
177- public void onPlayerStateChanged ( final boolean playWhenReady , final int playbackState ) {
174+ public void onPlaybackStateChanged ( final int playbackState ) {
178175 if (playbackState == Player .STATE_BUFFERING ) {
179176 sendBufferingUpdate ();
180177 } else if (playbackState == Player .STATE_READY ) {
0 commit comments