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();
//simpleProgressBar.setVisibility(View.INVISIBLE);
} else {
downloadFile();
}
}
});
}
private void downloadFile () {
started = true;
simpleProgressBar.setVisibility(View.VISIBLE);
//fileDownload.setEnabled(false);
@ -189,10 +197,6 @@ public class Downloader extends AppCompatActivity {
downloadFile.start();
downloadProgress.start();
}
}
});
}
private void performFileSearch(String messageTitle) {
//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) {
fileuri = resultData.getData();
System.out.println(fileuri.toString());
downloadFile();
//System.out.println("File selected successfully");
//System.out.println("content://com.android.externalstorage.documents"+file.getPath());
} else {

View file

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

View file

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