MediaRecorder start called in invalid state: 4

前端 未结 4 1478
孤街浪徒
孤街浪徒 2021-01-28 02:04

I\'ve just started getting into android/Glass development and I was trying to add basic video recording functionality. Currently Glass limits you to 10 seconds unless you tap/p

相关标签:
4条回答
  • 2021-01-28 02:25

    Open AndroidManifest file and inside application tag add this

    android:requestLegacyExternalStorage="true"
    
    0 讨论(0)
  • 2021-01-28 02:28

    I ran into the same issue on some Android devices. I was using Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) as the output for the MediaRecorder instance. After reading is3av's answer, I changed the output path to Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) and the problem is solved.

    Seems like some phones don't allow files to be written to Environment.DIRECTORY_MOVIES path or that path doesn't exist.

    0 讨论(0)
  • 2021-01-28 02:30

    Change your location to:

     Environment.getExternalStorageDirectory() + File.separator 
                + Environment.DIRECTORY_DCIM + File.separator + "FILE_NAME";
    

    This worked for me. Hope it helps!

    0 讨论(0)
  • 2021-01-28 02:35

    Try add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> to your AndroidManifest.xml

    0 讨论(0)
提交回复
热议问题