fix downloader

This commit is contained in:
Page Asgardius 2022-11-28 11:40:14 -07:00
parent c1c9aee8e3
commit 29ebb3d85b
3 changed files with 136 additions and 119 deletions

View file

@ -87,6 +87,14 @@ public class Downloader extends AppCompatActivity {
downloadFile.interrupt(); downloadFile.interrupt();
//simpleProgressBar.setVisibility(View.INVISIBLE); //simpleProgressBar.setVisibility(View.INVISIBLE);
} else { } else {
downloadFile();
}
}
});
}
private void downloadFile () {
started = true; started = true;
simpleProgressBar.setVisibility(View.VISIBLE); simpleProgressBar.setVisibility(View.VISIBLE);
//fileDownload.setEnabled(false); //fileDownload.setEnabled(false);
@ -189,10 +197,6 @@ public class Downloader extends AppCompatActivity {
downloadFile.start(); downloadFile.start();
downloadProgress.start(); downloadProgress.start();
} }
}
});
}
private void performFileSearch(String messageTitle) { private void performFileSearch(String messageTitle) {
//uri = Uri.parse("content://com.android.externalstorage.documents/document/home"); //uri = Uri.parse("content://com.android.externalstorage.documents/document/home");
@ -220,6 +224,7 @@ public class Downloader extends AppCompatActivity {
if (resultData != null && resultData.getData() != null) { if (resultData != null && resultData.getData() != null) {
fileuri = resultData.getData(); fileuri = resultData.getData();
System.out.println(fileuri.toString()); System.out.println(fileuri.toString());
downloadFile();
//System.out.println("File selected successfully"); //System.out.println("File selected successfully");
//System.out.println("content://com.android.externalstorage.documents"+file.getPath()); //System.out.println("content://com.android.externalstorage.documents"+file.getPath());
} else { } else {

View file

@ -69,6 +69,7 @@ public class VideoPlayer extends AppCompatActivity {
private PlayerNotificationManager playerNotificationManager; private PlayerNotificationManager playerNotificationManager;
private int notificationId = 1234; private int notificationId = 1234;
boolean hls; boolean hls;
boolean success = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -159,6 +160,9 @@ public class VideoPlayer extends AppCompatActivity {
public void onPlayerError(PlaybackException error) { public void onPlayerError(PlaybackException error) {
Throwable cause = error.getCause(); Throwable cause = error.getCause();
if(success) {
player.pause();
} else {
if (cause instanceof HttpDataSource.HttpDataSourceException) { if (cause instanceof HttpDataSource.HttpDataSourceException) {
// An HTTP error occurred. // An HTTP error occurred.
//System.out.println("Playback error F"); //System.out.println("Playback error F");
@ -171,6 +175,7 @@ public class VideoPlayer extends AppCompatActivity {
player.release(); player.release();
finish(); finish();
} }
}
}); });
@ -180,6 +185,7 @@ public class VideoPlayer extends AppCompatActivity {
public void onPlaybackStateChanged(@Player.State int state) { public void onPlaybackStateChanged(@Player.State int state) {
if (state == 3) { if (state == 3) {
// Active playback. // Active playback.
success = true;
//Acquiring WakeLock and WifiLock if not held //Acquiring WakeLock and WifiLock if not held
if (!mWifiLock.isHeld()) { if (!mWifiLock.isHeld()) {
mWifiLock.acquire(); mWifiLock.acquire();

View file

@ -69,6 +69,7 @@ public class VideoPlayerPip extends AppCompatActivity {
private PlayerNotificationManager playerNotificationManager; private PlayerNotificationManager playerNotificationManager;
private int notificationId = 1234; private int notificationId = 1234;
boolean hls; boolean hls;
boolean success = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -159,6 +160,9 @@ public class VideoPlayerPip extends AppCompatActivity {
public void onPlayerError(PlaybackException error) { public void onPlayerError(PlaybackException error) {
Throwable cause = error.getCause(); Throwable cause = error.getCause();
if(success) {
player.pause();
} else {
if (cause instanceof HttpDataSource.HttpDataSourceException) { if (cause instanceof HttpDataSource.HttpDataSourceException) {
// An HTTP error occurred. // An HTTP error occurred.
//System.out.println("Playback error F"); //System.out.println("Playback error F");
@ -171,6 +175,7 @@ public class VideoPlayerPip extends AppCompatActivity {
player.release(); player.release();
finish(); finish();
} }
}
}); });
@ -180,6 +185,7 @@ public class VideoPlayerPip extends AppCompatActivity {
public void onPlaybackStateChanged(@Player.State int state) { public void onPlaybackStateChanged(@Player.State int state) {
if (state == 3) { if (state == 3) {
// Active playback. // Active playback.
success = true;
//Acquiring WakeLock and WifiLock if not held //Acquiring WakeLock and WifiLock if not held
if (!mWifiLock.isHeld()) { if (!mWifiLock.isHeld()) {
mWifiLock.acquire(); mWifiLock.acquire();