为什么我会收到此错误消息:&quot“”不包含MediaExtractor的定义。与xamarin.forms?

发布于 2025-01-24 00:02:57 字数 3020 浏览 0 评论 0原文

我正在开发一个也可以直播视频的应用程序,但是我有一些问题。

我已经通过Nuget下载并安装了plugin.mediamanager.forms.forms(以及plugin.mediamanager)。我还可以在下面看到的那样完成了必要的事情:

在mainActivity.cs中(我是在引用MediaManager&我也初始化了CrossMediaManager)

    using Android.App;
    using Android.Content.PM;
    using Android.Runtime;
    using Android.OS;
    using MediaManager;
    namespace Abuse_Alert.Droid
    {
       [Activity(Label = "Abuse_Alert", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]

   public class MainActivity : 
   global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
   {
    protected override void OnCreate(Bundle savedInstanceState)
    {
        CrossMediaManager.Current.Init(this);

        base.OnCreate(savedInstanceState);

        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    }
    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }
   }
    }

XAML文件看起来像这样:

<?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="AbuseAlert.Views.Page1"
         xmlns:mm="clr-namespace:MediaManager.Forms;assembly=MediaManager.Forms"
         x:Name="BrowseItemsPage">

<ContentPage.Content>
<mm:VideoView VerticalOptions="FillAndExpand"
              HorizontalOptions="FillAndExpand"
              BackgroundColor="Black"
              x:Name="mmVideoView"
              />
</ContentPage.Content>

</ContentPage>

在背后的代码中,这就是我所做的:

    if (isHLS)
    {
      var item2 = await CrossMediaManager.Current.MediaExtractor.CreateMediaItem(URL);

      item2.MediaType = MediaManager.Media.MediaType.Hls;
      CrossMediaManager.Current.MediaPlayer.VideoView.ShowControls = false;

      await CrossMediaManager.Current.Play(item2);
   }
   else
   {
      await CrossMediaManager.Current.Play(URL);
   }

尽管如此,这些我在上面3中收到的错误消息是:

  1. 名称'ishls'在当前上下文中不存在

  2. 'imediaManager'不包含“ MediaExtractor”的定义,也不包含可访问的定义 扩展方法“ MediaExtractor”接受类型的第一个参数为“ ImediaManager” 可以找到(您是否缺少使用指令或装配给参考?)

  3. 命名空间中不存在类型或名称名称'Mediatype' 'MediaManager.Media'(您是否缺少汇编参考?)

  4. 'ivideoview'不包含“ ShowControls”的定义,也不可访问 扩展方法“ showcontrols”接受类型“ ivideoview”的第一个参数可以 可以找到(您是否缺少使用指令或装配给参考?)

,那么,我应该做什么?我正在使用Xamarin.forms进行vs 2022。

I am developing an app that can also Livestream Video, but I am having some issues.

I have downloaded and installed Plugin.MediaManager.Forms (and also Plugin.MediaManager) via Nuget. I have also done the needful as you can see below:

In MainActivity.cs (I am referencing MediaManager & I also Initialized CrossMediaManager)

    using Android.App;
    using Android.Content.PM;
    using Android.Runtime;
    using Android.OS;
    using MediaManager;
    namespace Abuse_Alert.Droid
    {
       [Activity(Label = "Abuse_Alert", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]

   public class MainActivity : 
   global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
   {
    protected override void OnCreate(Bundle savedInstanceState)
    {
        CrossMediaManager.Current.Init(this);

        base.OnCreate(savedInstanceState);

        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    }
    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }
   }
    }

The XAml File looks like this:

<?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="AbuseAlert.Views.Page1"
         xmlns:mm="clr-namespace:MediaManager.Forms;assembly=MediaManager.Forms"
         x:Name="BrowseItemsPage">

<ContentPage.Content>
<mm:VideoView VerticalOptions="FillAndExpand"
              HorizontalOptions="FillAndExpand"
              BackgroundColor="Black"
              x:Name="mmVideoView"
              />
</ContentPage.Content>

</ContentPage>

In the code behind, this is what I have done:

    if (isHLS)
    {
      var item2 = await CrossMediaManager.Current.MediaExtractor.CreateMediaItem(URL);

      item2.MediaType = MediaManager.Media.MediaType.Hls;
      CrossMediaManager.Current.MediaPlayer.VideoView.ShowControls = false;

      await CrossMediaManager.Current.Play(item2);
   }
   else
   {
      await CrossMediaManager.Current.Play(URL);
   }

Nevertheless, these are the error messages I am getting in 3 above:

  1. The name 'isHLS' does not exist in the current context

  2. 'IMediaManager' does not contain a definition for 'MediaExtractor' and no accessible
    extension method 'MediaExtractor' accepting a first argument of type 'IMediaManager'
    could be found (are you missing a using directive or an assembly reference?)

  3. The type or namespace name 'MediaType' does not exist in the namespace
    'MediaManager.Media' (are you missing an assembly reference?)

  4. 'IVideoView' does not contain a definition for 'ShowControls' and no accessible
    extension method 'ShowControls' accepting a first argument of type 'IVideoView' could
    be found (are you missing a using directive or an assembly reference?)

So, what am I supposed to have done that I have not done? I am using VS 2022 with xamarin.forms.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文