mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Do not mux video and audio on Android 7 and below.
This commit is contained in:
parent
42a935981d
commit
974730db1a
@ -25,6 +25,7 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.core.app.NotificationChannelCompat;
|
import androidx.core.app.NotificationChannelCompat;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
@ -98,7 +99,7 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
Bundle intent = msg.getData();
|
Bundle intent = msg.getData();
|
||||||
String videoUrl = intent.getString(EXTRA_VIDEO_URL);
|
String videoUrl = intent.getString(EXTRA_VIDEO_URL);
|
||||||
String audioUrl = videoUrl.substring(0, videoUrl.lastIndexOf('/')) + "/DASH_audio.mp4";
|
String audioUrl = Build.VERSION.SDK_INT > Build.VERSION_CODES.N ? videoUrl.substring(0, videoUrl.lastIndexOf('/')) + "/DASH_audio.mp4" : null;
|
||||||
String subredditName = intent.getString(EXTRA_SUBREDDIT);
|
String subredditName = intent.getString(EXTRA_SUBREDDIT);
|
||||||
String fileNameWithoutExtension = subredditName + "-" + intent.getString(EXTRA_POST_ID);
|
String fileNameWithoutExtension = subredditName + "-" + intent.getString(EXTRA_POST_ID);
|
||||||
boolean isNsfw = intent.getBoolean(EXTRA_IS_NSFW, false);
|
boolean isNsfw = intent.getBoolean(EXTRA_IS_NSFW, false);
|
||||||
@ -221,6 +222,7 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (audioUrl != null) {
|
||||||
Response<ResponseBody> audioResponse = downloadFile.downloadFile(audioUrl).execute();
|
Response<ResponseBody> audioResponse = downloadFile.downloadFile(audioUrl).execute();
|
||||||
if (audioResponse.isSuccessful() && audioResponse.body() != null) {
|
if (audioResponse.isSuccessful() && audioResponse.body() != null) {
|
||||||
String audioFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp3";
|
String audioFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp3";
|
||||||
@ -265,6 +267,18 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
downloadFinished(null, ERROR_MUXED_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset);
|
downloadFinished(null, ERROR_MUXED_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
updateNotification(R.string.downloading_reddit_video_save_file_to_public_dir, -1,
|
||||||
|
randomNotificationIdOffset, null);
|
||||||
|
try {
|
||||||
|
Uri destinationFileUri = copyToDestination(videoFilePath, destinationFileUriString, destinationFileName, isDefaultDestination);
|
||||||
|
new File(videoFilePath).delete();
|
||||||
|
downloadFinished(destinationFileUri, NO_ERROR, randomNotificationIdOffset);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
downloadFinished(null, ERROR_MUXED_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
downloadFinished(null, ERROR_VIDEO_FILE_CANNOT_DOWNLOAD, randomNotificationIdOffset);
|
downloadFinished(null, ERROR_VIDEO_FILE_CANNOT_DOWNLOAD, randomNotificationIdOffset);
|
||||||
}
|
}
|
||||||
@ -325,6 +339,7 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean muxVideoAndAudio(String videoFilePath, String audioFilePath, String outputFilePath) {
|
private boolean muxVideoAndAudio(String videoFilePath, String audioFilePath, String outputFilePath) {
|
||||||
|
Log.i("asdfasdf", "sasdfasdf");
|
||||||
try {
|
try {
|
||||||
File file = new File(outputFilePath);
|
File file = new File(outputFilePath);
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
Loading…
Reference in New Issue
Block a user