简体   繁体   English

如何在Xamarin.Forms中录制视频

[英]How to record a video in Xamarin.Forms

I am using Xam.Plugin.Media to take photo and video. 我正在使用Xam.Plugin.Media拍摄照片和视频。 The code below is to record the video the problem is the camera is not opening when I click the button. 下面的代码用于记录视频,问题是单击按钮时相机未打开。 I tried to uninstall and install the Nuget package and deleted the bin and obj still nothing. 我试图卸载并安装Nuget软件包,并删除了bin和obj仍然一无所有。 I also tried different phones with different api still nothing worked. 我还尝试了具有不同api的不同手机,但仍然行不通。 I hope you can help me 我希望你能帮帮我

try
{
   var cafNo = entCafNo.Text;

   await CrossMedia.Current.Initialize();

   if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported)
   {
      await DisplayAlert("No Camera", "No Camera Available", "Ok");
      return;
   }

   var file = await CrossMedia.Current.TakeVideoAsync(
   new Plugin.Media.Abstractions.StoreVideoOptions
   {
        SaveToAlbum = false,
        Name = cafNo + "_VID.mp4",
        CompressionQuality = 80,
        Quality = VideoQuality.Low
   }
   );

   entVideoUrl.Text = file.Path;

}
catch (Exception ex)
{
   Console.Write(ex.Message);
}

Android security architecture provision: by default, no application has permission to perform any action that adversely affects other applications, operating systems, or users. Android安全体系结构规定:默认情况下,没有应用程序有权执行对其他应用程序,操作系统或用户产生不利影响的任何操作。 This includes reading and writing users' private data (such as contacts or emails), reading and writing files from other applications, performing network access, keeping devices awake, performing camera access,and so on. 这包括读取和写入用户的私人数据(例如联系人或电子邮件),从其他应用程序读取和写入文件,执行网络访问,使设备保持唤醒状态,执行摄像头访问等等。

To use these protected device capabilities, first add one or more < uses-permission > tags in the application manifest file (androidmanifest.xml). 要使用这些受保护的设备功能,请首先在应用清单文件(androidmanifest.xml)中添加一个或多个<uses-permission>标签。

In xamarin.forms,you can refer to the link here 在xamarin.forms中,您可以在这里参考链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM