System.NotImplementedException: '此程序集的便携版本中未实现此功能

System.NotImplementedException: 'This functionality is not implemented in the portable version of this assembly

我已将 Plugin.MediaManagerPlugin.MediaManager.Forms 添加到我的 xamarin forms 项目中以播放视频。

CrossMediaManager.Current.Init(this);

当我尝试添加以上代码时,它显示错误(方法 Init() 没有重载;)

但是当 运行 具有以下代码行的项目时,android 出现以下异常。

CrossMediaManager.Current.Init();

System.NotImplementedException: 'This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.'

IOS 和 UWP 应用程序运行良好,只有 android 项目存在此问题。请帮我解决这个问题。

System.NotImplementedException: 'This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.'

上面的错误经常出现在Android目标版本较低的时候。这是一个类似的问题,您可以查看 https://github.com/martijn00/XamarinMediaManager/issues/437 .

另外,对于你的情况。你应该确保视频 url 的格式是 xxx.mp4 。插件无法支持这种格式的 url(player.vimeo.com/video/361089481).

在此插件的早期版本中 Android 的初始化 是:

CrossMediaManager.Current.Init();

我刚刚更新了 nuget 中的所有包,包括 xamarin.forms,将 Target 框架更改为 API 29,并在 Android 中更改了

CrossMediaManager.Current.Init();

CrossMediaManager.Current.Init(this);

现在可以工作了。

  • Plugin.MediaManager v0.9.7
  • Plugin.MediaManager.Forms v0.9.7
  • Xamarin.Forms v4.5.0.495

我已经将编译版本更新到 10.0 并为我工作。

Android 项目引用了net standard 2.0,所以init方法没有带参数。我查看了 android dll 的 plugin.mediamanager 包文件夹,它是 monoandroid10.0