【问题标题】:Video recording doesn't stop even after max duration for it finishes in android xamarin即使在 android xamarin 中完成最长持续时间后,视频录制也不会停止
【发布时间】:2015-01-27 15:24:24
【问题描述】:

我想让用户在我的应用中录制最长 2 分钟的视频。 我确实在我的代码中提供了视频录制意图的最大持续时间,但在那之后录像机并没有停止。我需要为此做些什么?

这是使用 Intent 录制视频的代码。

private void TakeAVideo()
        {
            Intent intent = new Intent(MediaStore.ActionVideoCapture);

            RecorderFile._file = new File(RecorderFile._dir, String.Format("vm_movie_{0}.mp4", Guid.NewGuid()));

            if (IsFrontCameraAvailable) {
                intent.PutExtra ("android.intent.extras.CAMERA_FACING", 1);
            } else {
                intent.PutExtra ("android.intent.extras.CAMERA_FACING", 0);
            }
            intent.PutExtra (MediaStore.ExtraDurationLimit, 120000);
            intent.PutExtra (MediaStore.ExtraVideoQuality, 0);
            intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(RecorderFile._file));

            StartActivityForResult(intent, 0);
        }

【问题讨论】:

    标签: c# android xamarin video-capture


    【解决方案1】:

    好的。我想到了。基本上,当我们使用intent 捕捉视频时,我们应该通过 No of Seconds 来设置最大持续时间,当我们使用MediaRecorder 录制时,我们应该以毫秒为单位设置最大持续时间。

    使用intent设置最大持续时间

    intent.PutExtra (MediaStore.ExtraDurationLimit, yourDurationInSeconds);

    使用MediaRecorder设置最大持续时间

    mediaRecorderObject.SetMaximumDuration(youDurationInMilliSeconds);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-17
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      相关资源
      最近更新 更多