|
4 | 4 | import android.content.Intent; |
5 | 5 | import android.net.Uri; |
6 | 6 | import android.os.Bundle; |
7 | | -import androidx.appcompat.app.AppCompatActivity; |
8 | 7 | import android.view.View; |
9 | 8 | import android.view.ViewGroup; |
10 | | -import android.widget.*; |
| 9 | +import android.widget.AdapterView; |
| 10 | +import android.widget.Button; |
| 11 | +import android.widget.ListView; |
| 12 | +import android.widget.RelativeLayout; |
| 13 | +import android.widget.SeekBar; |
| 14 | + |
| 15 | +import androidx.appcompat.app.AppCompatActivity; |
11 | 16 |
|
12 | 17 | import com.daasuu.gpuv.egl.filter.GlFilter; |
13 | 18 | import com.daasuu.gpuv.player.GPUPlayerView; |
14 | 19 | import com.daasuu.gpuvideoandroid.widget.MovieWrapperView; |
15 | 20 | import com.daasuu.gpuvideoandroid.widget.PlayerTimer; |
16 | | -import com.google.android.exoplayer2.ExoPlayerFactory; |
| 21 | +import com.google.android.exoplayer2.MediaItem; |
17 | 22 | import com.google.android.exoplayer2.SimpleExoPlayer; |
18 | | -import com.google.android.exoplayer2.source.ExtractorMediaSource; |
19 | | -import com.google.android.exoplayer2.source.MediaSource; |
20 | 23 | import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; |
21 | | -import com.google.android.exoplayer2.trackselection.TrackSelector; |
22 | | -import com.google.android.exoplayer2.upstream.DataSource; |
23 | | -import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; |
24 | | -import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; |
25 | | -import com.google.android.exoplayer2.util.Util; |
26 | 24 |
|
27 | 25 | import java.util.List; |
28 | 26 |
|
29 | 27 | public class PlayerActivity extends AppCompatActivity { |
30 | 28 |
|
31 | | - private static final String STREAM_URL_MP4_VOD_LONG = "https://www.radiantmediaplayer.com/media/bbb-360p.mp4"; |
| 29 | + private static final String STREAM_URL_MP4_VOD_LONG = "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4"; |
32 | 30 |
|
33 | 31 | public static void startActivity(Activity activity) { |
34 | 32 | Intent intent = new Intent(activity, PlayerActivity.class); |
@@ -152,21 +150,14 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
152 | 150 |
|
153 | 151 |
|
154 | 152 | private void setUpSimpleExoPlayer() { |
155 | | - |
156 | | - TrackSelector trackSelector = new DefaultTrackSelector(); |
157 | | - |
158 | | - // Measures bandwidth during playback. Can be null if not required. |
159 | | - DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter(); |
160 | | - // Produces DataSource instances through which media data is loaded. |
161 | | - DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "yourApplicationName"), defaultBandwidthMeter); |
162 | | - MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(STREAM_URL_MP4_VOD_LONG)); |
163 | | - |
164 | 153 | // SimpleExoPlayer |
165 | | - player = ExoPlayerFactory.newSimpleInstance(this, trackSelector); |
166 | | - // Prepare the player with the source. |
167 | | - player.prepare(mediaSource); |
168 | | - player.setPlayWhenReady(true); |
| 154 | + player = new SimpleExoPlayer.Builder(this) |
| 155 | + .setTrackSelector(new DefaultTrackSelector(this)) |
| 156 | + .build(); |
169 | 157 |
|
| 158 | + player.addMediaItem(MediaItem.fromUri(Uri.parse(STREAM_URL_MP4_VOD_LONG))); |
| 159 | + player.prepare(); |
| 160 | + player.setPlayWhenReady(true); |
170 | 161 | } |
171 | 162 |
|
172 | 163 |
|
|
0 commit comments