play queue

This commit is contained in:
Page Asgardius 2023-01-02 12:07:30 -07:00
parent c3cf489510
commit 48fa899a97
2 changed files with 41 additions and 17 deletions

View file

@ -458,7 +458,6 @@ public class ObjectSelect extends AppCompatActivity {
}
private void videoPlayer(String url, String title) {
if (isplaylist) {
Thread mediaread = new Thread(new Runnable() {
@ -473,10 +472,6 @@ public class ObjectSelect extends AppCompatActivity {
}
}
ArrayList<String> links = getLinks(medialist);
for (int i = 0; i < links.size(); i++) {
System.out.println(links.get(i));
}
System.out.println("Position of selected file: "+medialist.indexOf(title));
runOnUiThread(new Runnable() {
@ -484,6 +479,15 @@ public class ObjectSelect extends AppCompatActivity {
public void run() {
// Sending reference and data to Adapter
//videoPlayer(objectURL.toString(), Name.get(position).toString());
Intent intent = new Intent(getApplicationContext(), VideoPlayer.class);
intent.putExtra("video_url", url);
intent.putExtra("title", title);
intent.putExtra("videocache", videocache);
intent.putExtra("buffersize", buffersize);
intent.putExtra("isplaylist", isplaylist);
intent.putExtra("queue", links);
intent.putExtra("names", medialist);
startActivity(intent);
}
});
//System.out.println("tree "+treelevel);

View file

@ -127,13 +127,6 @@ public class VideoPlayer extends AppCompatActivity {
new File(this.getCacheDir(), "media"),
evictor,
standaloneDatabaseProvider);
mediaSource = new ProgressiveMediaSource.Factory(
new CacheDataSource.Factory()
.setCache(simpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()
.setUserAgent("S3 Manager"))
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
).createMediaSource(MediaItem.fromUri(Uri.parse(videoURL)));
playerView.setPlayer(player);
control = new StyledPlayerView.ControllerVisibilityListener() {
@Override
@ -155,13 +148,40 @@ public class VideoPlayer extends AppCompatActivity {
playerNotificationManager = new PlayerNotificationManager.Builder(this, notificationId, "playback").build();
playerNotificationManager.setMediaSessionToken(mediaSession.getSessionToken());
playerNotificationManager.setPlayer(player);
if (isplaylist) {
for (int i = 0; i < queue.size(); i++) {
if (names.get(i).endsWith(".m3u8")) {
MediaItem mediaItem = MediaItem.fromUri(queue.get(i));
player.addMediaItem(mediaItem);
} else {
mediaSource = new ProgressiveMediaSource.Factory(
new CacheDataSource.Factory()
.setCache(simpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()
.setUserAgent("S3 Manager"))
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
).createMediaSource(MediaItem.fromUri(Uri.parse(queue.get(i))));
player.addMediaSource(mediaSource);
}
}
player.prepare();
player.seekTo(names.indexOf(title), 0);
} else {
if (title.endsWith(".m3u8")) {
MediaItem mediaItem = MediaItem.fromUri(videoURL);
player.setMediaItem(mediaItem);
} else {
mediaSource = new ProgressiveMediaSource.Factory(
new CacheDataSource.Factory()
.setCache(simpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()
.setUserAgent("S3 Manager"))
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
).createMediaSource(MediaItem.fromUri(Uri.parse(videoURL)));
player.setMediaSource(mediaSource);
}
player.prepare();
}
// Start the playback.
player.play();