diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-02-02 14:47:18 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-02-02 14:47:18 +0000 |
commit | b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6 (patch) | |
tree | 26b989c720a0b2c78428fa95c092cc103150075c /app/src | |
parent | 6ffe6a6432dcfe5a94b8b897e9dd6fc751a9a3dc (diff) | |
download | infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.tar infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.tar.gz infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.tar.bz2 infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.tar.lz infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.tar.xz infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.tar.zst infinity-for-reddit-b7b9a7f3bd0c7c7d5dd3ed86db7c0929defb1ba6.zip |
Fix downloading videos without sound failed.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java index 73839464..f1b9633e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java @@ -25,6 +25,7 @@ import android.os.Looper; import android.os.Message; import android.os.Process; import android.provider.MediaStore; +import android.util.Log; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; @@ -207,17 +208,18 @@ public class DownloadRedditVideoService extends Service { updateNotification(R.string.downloading_reddit_video_audio_track, 0, randomNotificationIdOffset, null); + String videoFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp4"; + String savedVideoFilePath = writeResponseBodyToDisk(videoResponse.body(), videoFilePath); + if (savedVideoFilePath == null) { + downloadFinished(null, ERROR_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset); + return; + } + Response<ResponseBody> audioResponse = downloadFile.downloadFile(audioUrl).execute(); if (audioResponse.isSuccessful() && audioResponse.body() != null) { - String videoFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp4"; String audioFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp3"; String outputFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + ".mp4"; - String savedVideoFilePath = writeResponseBodyToDisk(videoResponse.body(), videoFilePath); - if (savedVideoFilePath == null) { - downloadFinished(null, ERROR_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset); - return; - } String savedAudioFilePath = writeResponseBodyToDisk(audioResponse.body(), audioFilePath); if (savedAudioFilePath == null) { downloadFinished(null, ERROR_AUDIO_FILE_CANNOT_SAVE, randomNotificationIdOffset); @@ -246,8 +248,6 @@ public class DownloadRedditVideoService extends Service { downloadFinished(null, ERROR_MUXED_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset); } } else { - String videoFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp4"; - updateNotification(R.string.downloading_reddit_video_save_file_to_public_dir, -1, randomNotificationIdOffset, null); try { |