List of usage examples for android.os Environment DIRECTORY_MOVIES
String DIRECTORY_MOVIES
To view the source code for android.os Environment DIRECTORY_MOVIES.
Click Source Link
From source file:com.aengbee.android.leanback.ui.VideoDetailsFragment.java
public void start(String company, String number, String duration) { if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) || ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) { // Provide an additional rationale to the user if the permission was not granted // and the user would benefit from additional context for the use of the permission. // For example, if the request has been denied previously. Toast.makeText(getActivity(), "we need read and write permission on external storage for downloading the videos and the mixing", Toast.LENGTH_LONG).show(); } else {/*ww w.ja v a2s .c o m*/ // Contact permissions have not been granted yet. Request them directly. ActivityCompat.requestPermissions(getActivity(), PERMISSIONS_STORAGE, 1); } } else { File tempaudio = new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/temp.mp3"); File templyrics = new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/temp.ass"); if (tempaudio.exists()) { tempaudio.delete(); } if (templyrics.exists()) { templyrics.delete(); } if (PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean(getString(R.string.pref_key_USB), false) == true) { String storagePath = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString("USB_path", "null"); File lyricsFrom = new File( String.format(storagePath + "/%s/%s/%s.ass", company, number.substring(0, 2), number)); File lyricsTo = new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/temp.ass"); //Toast.makeText(getActivity(),lyricsFrom.toString()+lyricsFrom.exists(),Toast.LENGTH_LONG).show(); File audioFrom = new File( String.format(storagePath + "/%s/%s/%s.mp3", company, number.substring(0, 2), number)); File audioTo = new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/temp.mp3"); //Toast.makeText(getActivity(),audioFrom.toString()+lyricsFrom.exists(),Toast.LENGTH_LONG).show(); try { Files.copy(lyricsFrom, lyricsTo); Files.copy(audioFrom, audioTo); } catch (IOException e) { e.printStackTrace(); } File source = new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/source.mp4"); if (!source.exists()) { File videoFrom = new File(String.format(storagePath + "/%s", "source.mp4")); File videoTo = new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/source.mp4"); Toast.makeText(getActivity(), videoFrom.toString() + lyricsFrom.exists(), Toast.LENGTH_LONG) .show(); try { Files.copy(videoFrom, videoTo); } catch (IOException e) { e.printStackTrace(); } } } else { String downloadURL = String.format("http://fytoz.asuscomm.com/4TB/%s/%s/%s.mp3", company, number.substring(0, 2), number); new DownloadTask(getActivity()).execute( Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES, "temp.ass", downloadURL.replace(".mp3", ".ass"), "SearchFragment"); new DownloadTask(getActivity()).execute( Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES, "temp.mp3", downloadURL, "SearchFragment"); } //Log.d("dxd", "start: "+downloadURL); String cmdFormat = "-i %s -i %s -c copy -map 0:v:0 -map 1:a:0 %s-y %s"; //List<String> fileList = getListFiles(getExternalStoragePublicDirectory(DIRECTORY_MOVIES),"mp4"); //List<String> fileList = getListFiles(new File(Environment.getExternalStorageDirectory().getPath()+"/"+Environment.DIRECTORY_MOVIES),"mp4"); String filePath = chooseVideo(duration); int lengthofFile = filePath.contains("source.mp4") ? 900 : getDurationVideo(new File(filePath)); //String joined = TextUtils.join(", ", fileList); //Toast.makeText(getActivity(), joined, Toast.LENGTH_SHORT).show(); //Log.d("dxd", "start: "+duration+"|"+lengthofFile); String shortest = Integer.parseInt(duration) > lengthofFile ? "-shortest " : "-shortest "; //Toast.makeText(getActivity(), shortest+duration+"|"+lengthofFile, Toast.LENGTH_LONG).show(); String audioPath = Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/temp.mp3"; String cmd1 = String.format(cmdFormat, filePath, audioPath, shortest, Environment.getExternalStorageDirectory().getPath() + "/" + DIRECTORY_MOVIES + "/temp.mkv"); String cmd2 = String.format(cmdFormat, PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean(getString(R.string.pref_key_USB), false) ? Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/source.mp4" : "http://fytoz.asuscomm.com/4TB/audio/source.mp4", audioPath, shortest, Environment.getExternalStorageDirectory().getPath() + "/" + DIRECTORY_MOVIES + "/temp.mkv"); //Log.d("kkk:", Environment.getExternalStorageDirectory().getPath()+"/"+Environment.DIRECTORY_MOVIES); String[] command1 = cmd1.split(" "); String[] command2 = cmd2.split(" "); if (new File(filePath).exists() && tempaudio.exists() && templyrics.exists()) { //Toast.makeText(getActivity(), cmd1, Toast.LENGTH_LONG).show(); ((VideoDetailsActivity) getActivity()).execFFmpegBinary(command1); } else { //Toast.makeText(getActivity(), cmd2, Toast.LENGTH_LONG).show(); ((VideoDetailsActivity) getActivity()).execFFmpegBinary(command2); } } }
From source file:com.irccloud.android.activity.VideoPlayerActivity.java
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (grantResults.length == 2 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) { DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); if (d != null) { DownloadManager.Request r = new DownloadManager.Request(Uri.parse(getIntent().getDataString() .replace(getResources().getString(R.string.VIDEO_SCHEME), "http"))); r.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, getIntent().getData().getLastPathSegment()); r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); r.allowScanningByMediaScanner(); d.enqueue(r);//ww w . j a v a 2 s. co m Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod("Download")); } } else { Toast.makeText(this, "Unable to download: permission denied", Toast.LENGTH_SHORT).show(); } }
From source file:com.juce.JuceAppActivity.java
public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); }
From source file:com.BeatYourRecord.SubmitActivity.java
private File initFile() { File k;/*from w ww. j av a 2 s . co m*/ File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), this.getClass().getPackage().getName()); if (!dir.exists() && !dir.mkdirs()) { k = null; } else { k = new File(dir.getAbsolutePath(), new SimpleDateFormat("'BYR_tournName_dateTim_'yyyyMMddHHmmss'.mp4'").format(new Date())); } return k; }
From source file:com.juce.jucedemo.JuceDemo.java
public static final String getMoviesFolder() { return getFileLocation(Environment.DIRECTORY_MOVIES); }