Code: Select all
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);
}
< /code>
Dies i Was ich in der Manifestdatei hinzugefügt habe: < /p>
< /code>
Dies ist der Pfad, der zum Laden des Videos zeigt: < /p>
String path = "/storage/emulated/0/Android/data/com.shliama.augmentedvideotutorial/files/NewVisionARVideos/test.mp4";
< /code>
Unten ist der Fehler, den ich bekomme, wenn ich versuche, das Video im Media Player abzuspielen. Der Pfad ist korrekt und ich habe die Berechtigungen im Manifest und auch im Telefon aktiviert.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