Advertisement
Guest User

Untitled

a guest
May 4th, 2017
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. I have an intent for filming videos and activity with VideoView for payback. Problem is that VideoView reports a problem "Unable to open content" because saved video file has 0 bytes.
  2.  
  3. Here is how I start video intent:
  4.  
  5.                 MediaButton button = buttons.get(buttons.size() - 1);
  6.  
  7.                 File video = button.createFile(button.getTimeID() + ".mp4");
  8.  
  9.                 if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  10.                     videoUri = FileProvider.getUriForFile(this, "rs.fintechpro.zigsafe.provider", video);
  11.                 }else {
  12.                     videoUri = Uri.fromFile(video);
  13.                 }
  14.  
  15.                 Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
  16.                 takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
  17.                 takeVideoIntent.putExtra(MediaStore.EXTRA_FULL_SCREEN, 1);
  18.                 takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
  19.                 takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60);
  20.                 takeVideoIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  21.                 takeVideoIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  22.                 takeVideoIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
  23.  
  24.                 startActivityForResult(takeVideoIntent, 1);
  25.  
  26. button.createFile() returns File object in /data/data/ which is achieved by calling Context.getFilesDir()
  27.  
  28. Big thanks!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement