Код: Выделить всё
public static void DownloadVideo(Context context, String URL) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(URL));
Date date = new Date();
SimpleDateFormat videoName = new SimpleDateFormat("yyyymmdd_HHmmss");
String strDate = videoName.format(date);
request.setDescription("Setting up the AR");
request.setTitle("AR setup ...");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
request.setDestinationInExternalFilesDir(context, "/NewVisionARVideos/", "" + strDate + System.currentTimeMillis() + ".mp4");
System.out.println("count files --- " + context.getExternalFilesDir(null).listFiles());
for(int i = 0; i < context.getExternalFilesDir(null).listFiles().length; i++){
System.out.println("** each file -- " + context.getExternalFilesDir(null).listFiles()[i]);
}
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
}
Код: Выделить всё
Код: Выделить всё
String path = "/storage/emulated/0/Android/data/com.shliama.augmentedvideotutorial/files/NewVisionARVideos/test.mp4";
Ниже появляется ошибка:
Код: Выделить всё
D/ArVideoFragment: playbackVideo = /storage/emulated/0/Android/data/com.shliama.augmentedvideotutorial/files/NewVisionARVideos/test.mp4
E/ArVideoFragment: Could not play video [/storage/emulated/0/Android/data/com.shliama.augmentedvideotutorial/files/NewVisionARVideos/test.mp4]
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.shliama.augmentedvideotutorial/files/NewVisionARVideos/test.mp4
РЕДАКТИРОВАТЬ:
На самом деле, я обнаружил, что указывал на папку ресурсов, так как следил за этим сообщением в блоге.
Это метод, который указывает на папку ресурсов
https:// gist.github.com/huxaiphaer/268b94a0e7959822fa679a7523701187
Подробнее здесь: https://stackoverflow.com/questions/629 ... d-data-com