Nexus6 无法播放此视频

Nexus6 Can't play this video

我关注这个[示例][1] 是为了了解如何使用 Android 摄像机。

我的 activity 的代码只是一个按钮和一个 VideoView。 点击按钮后我录制了一段视频,然后在停止录制后,录制的视频在 VideoView 上可见。 该代码在 Galaxy S2(api16) 和华为 L21(api 22) 上完美运行,但在摩托罗拉 Nexus 6(api23) 上我遇到了这个错误

Can not play this video

这是我的 activity 文件:

public class MainActivity extends AppCompatActivity {

@Bind(R.id.button)
Button button;

@Bind(R.id.videoView)
VideoView videoView;

private Uri fileUri;
public static final int MEDIA_TYPE_VIDEO = 2;
private static final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
}

@OnClick(R.id.button)
protected void startRecording() {
    launchCamera();
}

private void launchCamera() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);  // create a file to save the video
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);  // set the image file name
    // set the video image quality to high
   startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
}

private  Uri getOutputMediaFileUri(int type) {
    Uri myUri =  Uri.fromFile(getOutputMediaFile(type));
    Log.d("TAG","uri we have is "+myUri);
    return myUri ;
}

private  File getOutputMediaFile(int type){

    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_MOVIES), "MyCameraApp");

    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            Log.d("MyCameraApp", "failed to create directory");
            return null;
        }
    }

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile;

        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "VID_"+ timeStamp + ".mp4");

    return mediaFile;
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            videoView.setVideoURI(fileUri);
            videoView.start();
}

}

以及我使用 Nexus6 获取的日志

 W/VideoView: Unable to open content: file:///storage/emulated/0/Movies/MyCameraApp/VID_20160503_132541.mp4
                                                                         java.io.IOException: setDataSource failed.
                                                                             at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1096)
                                                                             at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1042)
                                                                             at android.media.MediaPlayer.setDataSource(MediaPlayer.java:991)
                                                                             at android.widget.VideoView.openVideo(VideoView.java:348)
                                                                             at android.widget.VideoView.-wrap0(VideoView.java)
                                                                             at android.widget.VideoView.surfaceCreated(VideoView.java:624)
                                                                             at android.view.SurfaceView.updateWindow(SurfaceView.java:595)
                                                                             at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:243)
                                                                             at android.view.View.dispatchWindowVisibilityChanged(View.java:10214)

  [1]: http://developer.android.com/intl/es/guide/topics/media/camera.html

知道为什么在 Nexus 6 上不起作用吗?

相机版应用升级至3.2.045后修复。 这是相机应用程序本身的问题,而不是我发布的代码中的问题。