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.keithandthegirl.services.download.DownloadService.java
@TargetApi(8) @Override//from w w w. ja v a 2s .c o m protected void onHandleIntent(Intent requestIntent) { Log.v(TAG, "onHandleIntent : enter"); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mOriginalRequestIntent = requestIntent; Resource resourceType = Resource.valueOf(requestIntent.getStringExtra(RESOURCE_TYPE_EXTRA)); mCallback = requestIntent.getParcelableExtra(SERVICE_CALLBACK); Uri data = requestIntent.getData(); String urlPath = requestIntent.getStringExtra("urlpath"); String directory = requestIntent.getStringExtra("directory"); String filename = data.getLastPathSegment(); File root; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { switch (resourceType) { case MP3: root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS); break; case MP4: root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES); break; case M4V: root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES); break; case JPG: root = getExternalCacheDir(); filename = requestIntent.getLongExtra("id", -1) + ".jpg"; break; default: root = getExternalCacheDir(); break; } } else { root = Environment.getExternalStorageDirectory(); } File outputDir = new File(root, directory); outputDir.mkdirs(); File output = new File(outputDir, filename); if (output.exists()) { result = FragmentActivity.RESULT_OK; mCallback.send(result, getOriginalIntentBundle()); Log.v(TAG, "onHandleIntent : exit, image exists"); return; } switch (resourceType) { case MP3: Log.v(TAG, "onHandleIntent : saving mp3"); savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; case MP4: Log.v(TAG, "onHandleIntent : saving mp4"); savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; case M4V: Log.v(TAG, "onHandleIntent : saving m4v"); savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; case JPG: Log.v(TAG, "onHandleIntent : saving jpg"); saveBitmap(requestIntent.getStringExtra("filename"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; default: Log.w(TAG, "onHandleIntent : unknown extension '" + resourceType.getExtension() + "'"); mCallback.send(REQUEST_INVALID, getOriginalIntentBundle()); break; } Log.v(TAG, "onHandleIntent : exit"); }
From source file:mil.nga.giat.mage.sdk.utils.MediaUtility.java
public static File createVideoFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "MAGE_" + timeStamp; File movies = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES); File directory = new File(movies, "MAGE"); if (!directory.exists()) { directory.mkdirs();/*from w ww .j a v a 2 s .c om*/ } return File.createTempFile(imageFileName, /* prefix */ ".mp4", /* suffix */ directory /* directory */ ); }
From source file:com.serenegiant.media.TLMediaEncoder.java
/** * constructor//from w w w .j a v a 2s . c o m * @param movie_name this values is used as a directory name for intermediate files * @param listener */ public TLMediaEncoder(final Context context, final String movie_name, final int type, final MediaEncoderListener listener) { if (DEBUG) Log.v(TAG, "TLMediaEncoder"); if (TextUtils.isEmpty(movie_name)) throw new IllegalArgumentException("movie_name should not be null"); mBaseDir = new File(context.getExternalFilesDir(Environment.DIRECTORY_MOVIES), movie_name); mBaseDir.mkdirs(); mType = type; mListener = listener; mBufferInfo = new MediaCodec.BufferInfo(); new Thread(mEncoderTask, getClass().getSimpleName()).start(); synchronized (mSync) { try { mSync.wait(); } catch (InterruptedException e) { // ignore } } }
From source file:com.albedinsky.android.support.intent.VideoIntent.java
/** * Same as {@link #createContentFile(String, String)} with <b>.mp4</b> suffix for the specified * <var>fileName</var> (if it does not contain any) and {@link Environment#DIRECTORY_MOVIES} * as <var>externalDirectoryType</var>. * * @param fileName The desired name for the video file. * @see #createVideoFile()/*from w w w .j av a 2s.co m*/ */ @Nullable public static File createVideoFile(@NonNull String fileName) { return ContentIntent.createContentFile(appendDefaultFileSuffixIfNotPresented(fileName, ".mp4"), Environment.DIRECTORY_MOVIES); }
From source file:com.wit.android.support.content.intent.VideoIntent.java
/** * Same as {@link #createContentFile(String, String, String)} with <b>.mp4</b> as <var>fileType</var> * and {@link android.os.Environment#DIRECTORY_MOVIES} as <var>environmentDirectoryType</var>. * * @param fileName Desired name for the video file. * @see #createVideoFile()/* w ww . j a va 2s . co m*/ */ @Nullable public static File createVideoFile(@NonNull String fileName) { return createContentFile(fileName, ".mp4", Environment.DIRECTORY_MOVIES); }
From source file:com.example.android.scopeddirectoryaccess.ScopedDirectoryAccessFragment.java
private String getDirectoryName(String name) { switch (name) { case "ALARMS": return Environment.DIRECTORY_ALARMS; case "DCIM": return Environment.DIRECTORY_DCIM; case "DOCUMENTS": return Environment.DIRECTORY_DOCUMENTS; case "DOWNLOADS": return Environment.DIRECTORY_DOWNLOADS; case "MOVIES": return Environment.DIRECTORY_MOVIES; case "MUSIC": return Environment.DIRECTORY_MUSIC; case "NOTIFICATIONS": return Environment.DIRECTORY_NOTIFICATIONS; case "PICTURES": return Environment.DIRECTORY_PICTURES; case "PODCASTS": return Environment.DIRECTORY_PODCASTS; case "RINGTONES": return Environment.DIRECTORY_RINGTONES; default:/* w w w . ja v a 2 s . c om*/ throw new IllegalArgumentException("Invalid directory representation: " + name); } }
From source file:com.colorchen.qbase.utils.FileUtil.java
/** * ?/*from w w w. j av a2 s .c om*/ * * @param context * @return */ public static String getDiskFileDir(Context context) { String cachePath = null; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { cachePath = context.getExternalFilesDir(Environment.DIRECTORY_MOVIES).getPath(); } else { cachePath = context.getFilesDir().getPath(); } return cachePath; }
From source file:com.simas.vc.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_concat: // ToDo ask user for a destination String destination = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) .getPath();//w w w .ja v a2 s . c om File output = new File(destination + File.separator + "output" + (++sNum) + ".mp4"); if (output.exists()) { //noinspection ResultOfMethodCallIgnored output.delete(); } try { // Concat videos FFmpeg.concat(output, sItems); } catch (IOException e) { Log.e(TAG, "Error!", e); new AlertDialog.Builder(this).setTitle(Utils.getString(R.string.error)) .setMessage("Unrecoverable error! Please try again.").setPositiveButton("OK...", null) .show(); } catch (VCException e) { Log.e(TAG, "Concatenation error:", e); new AlertDialog.Builder(this).setTitle(Utils.getString(R.string.error)).setMessage(e.getMessage()) .setPositiveButton("OK", null).show(); } return true; case R.id.action_add_item: // When adding a new item showFileChooser(true); return true; case R.id.action_settings: return true; } return super.onOptionsItemSelected(item); }
From source file:com.aengbee.android.leanback.ui.VideoDetailsFragment.java
public String chooseVideo(String durationSong) { int intDurationSong = Integer.parseInt(durationSong); List<String> fileList = getListFiles( new File(Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES), "mp4"); List<String> possibleList = new ArrayList<String>(); if (fileList.size() > 0) { for (String file : fileList) { int length = file.contains("mp4") ? 900 : getDurationVideo(new File(file)); if (length > intDurationSong) possibleList.add(file);//from w ww .j a va 2 s . c o m } } String result = ""; if (fileList == null || fileList.size() == 0 || possibleList == null || possibleList.size() < 1) { result = Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_MOVIES + "/source.mp4"; } else { if (possibleList.size() > 1) Collections.shuffle(possibleList); result = String.format(getExternalStoragePublicDirectory(DIRECTORY_MOVIES).toString() + "/%s", possibleList.get(0)); } return result; }
From source file:com.irccloud.android.activity.VideoPlayerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish();/* www . j a va2 s. co m*/ overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right); return true; } else if (item.getItemId() == R.id.action_download) { if (Build.VERSION.SDK_INT >= 16 && ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); } else { DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); if (d != null) { String uri = getIntent().getDataString() .replace(getResources().getString(R.string.VIDEO_SCHEME), "http"); DownloadManager.Request r = new DownloadManager.Request(Uri.parse(uri)); r.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, getIntent().getData().getLastPathSegment()); r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); r.allowScanningByMediaScanner(); d.enqueue(r); Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod("Download")); } } return true; } else if (item.getItemId() == R.id.action_copy) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newRawUri("IRCCloud Video URL", Uri.parse( getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http"))); clipboard.setPrimaryClip(clip); Toast.makeText(VideoPlayerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT).show(); Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod("Copy to Clipboard")); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && item.getItemId() == R.id.action_share) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse( getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http"))); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http")); intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName()); intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "Share Video")); Answers.getInstance().logShare(new ShareEvent().putContentType("Video")); } return super.onOptionsItemSelected(item); }