diff --git a/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt b/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt index 7de33363..f961301e 100644 --- a/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt +++ b/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt @@ -706,7 +706,12 @@ class VideoDownload { } else { Logger.i(TAG, "Download $name Sequential"); - sourceLength = downloadSource_Sequential(client, fileStream, videoUrl, onProgress); + try { + sourceLength = downloadSource_Sequential(client, fileStream, videoUrl, onProgress); + } catch (e: Throwable) { + Logger.w(TAG, "Failed to download sequentially (url = $videoUrl)") + throw e + } } Logger.i(TAG, "$name downloadSource Finished"); @@ -762,7 +767,7 @@ class VideoDownload { totalRead += read; readSinceLastSpeedTest += read; - if (totalRead / progressRate > lastProgressCount) { + if (totalRead.toDouble() / progressRate > lastProgressCount) { onProgress(sourceLength, totalRead, lastSpeed); lastProgressCount++; } diff --git a/app/src/main/java/com/futo/platformplayer/services/DownloadService.kt b/app/src/main/java/com/futo/platformplayer/services/DownloadService.kt index 39fc5562..04958a29 100644 --- a/app/src/main/java/com/futo/platformplayer/services/DownloadService.kt +++ b/app/src/main/java/com/futo/platformplayer/services/DownloadService.kt @@ -51,10 +51,10 @@ class DownloadService : Service() { private val _client = ManagedHttpClient(OkHttpClient.Builder() //.proxy(Proxy(Proxy.Type.HTTP, InetSocketAddress(InetAddress.getByName("192.168.1.175"), 8081))) - .readTimeout(Duration.ofSeconds(30)) - .writeTimeout(Duration.ofSeconds(30)) + .readTimeout(Duration.ofMinutes(30)) + .writeTimeout(Duration.ofMinutes(30)) .connectTimeout(Duration.ofSeconds(30)) - .callTimeout(Duration.ofMinutes(30))) + .callTimeout(Duration.ofMinutes(0))) private var _started = false;