Microsoft.Xna.Framework.Content.ContentLoadException on VideoPlayer in Microsoft.Xna.Framework.Media (Monogame)

huangapple go评论152阅读模式
英文:

Microsoft.Xna.Framework.Content.ContentLoadException on VideoPlayer in Microsoft.Xna.Framework.Media (Monogame)

问题

我正在尝试在Monogame中播放视频。我遇到了一些问题,因为最简单的方法是使用VideoPlayer,但由于某种原因,它不在我的Microsoft.Xna.Framework.Media中。所以我将我的Visual Studio项目指向了Microsoft.Xna.Framework.Video.dll这个引用,然后我成功地创建了一个VideoPlayer对象。

我的示例代码如下:

videoPlayer = new VideoPlayer();
video = content.Load<Video>("Intro_Videos/main_intro");
videoPlayer.Play(video);

我在第2行遇到了一个错误,

Microsoft.Xna.Framework.Content.ContentLoadException: '找不到ContentTypeReader类型。请确保包含该类型的程序集的名称与完整类型名称中的程序集匹配: Microsoft.Xna.Framework.Content.VideoReader (Microsoft.Xna.Framework.Content.VideoReader)'

更详细的错误信息如下:

Microsoft.Xna.Framework.Content.ContentLoadException
  HResult=0x80131500
  Message=找不到ContentTypeReader类型。请确保包含该类型的程序集的名称与完整类型名称中的程序集匹配: Microsoft.Xna.Framework.Content.VideoReader (Microsoft.Xna.Framework.Content.VideoReader)
  Source=MonoGame.Framework
  StackTrace:
   at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.LoadAssetReaders(ContentReader reader)
   at Microsoft.Xna.Framework.Content.ContentReader.InitializeTypeReaders()
   at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
   at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
   at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
   at DevcadeGame.States.IntroState..ctor(Game1 game, GraphicsDevice graphicsDevice, Int32 PreferredBackBufferWidth, Int32 PreferredBackBufferHeight, ContentManager content) in C:\Users\garre\Desktop\Devcade\Devcade-Hero\States\IntroState.cs:line 28
   at DevcadeGame.Game1.LoadContent() in C:\Users\garre\Desktop\Devcade\Devcade-Hero\Game1.cs:line 109
   at Microsoft.Xna.Framework.Game.Initialize()
   at DevcadeGame.Game1.Initialize() in C:\Users\garre\Desktop\Devcade\Devcade-Hero\Game1.cs:line 89
   at Microsoft.Xna.Framework.Game.DoInitialize()
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
   at Microsoft.Xna.Framework.Game.Run()
   at Program.<Main>$(String[] args) in C:\Users\garre\Desktop\Devcade\Devcade-Hero\Program.cs:line 3

一些背景信息是路径应该是正确的。视频是一个.mp4文件,项目中的资源构建得很好。我在x86(活动解决方案平台)上构建。

将以上信息提供给了你,希望能得到帮助。

英文:

I'm trying to play a video in Monogame. I was having a bit of trouble because the easiest way is to use VideoPlayer, which is not in my Microsoft.Xna.Framework.Media for some reason. So I pointed my visual studio project to reference Microsoft.Xna.Framework.Video.dll and I was able to make an object of VideoPlayer just fine.

My sample code is as follows:

videoPlayer = new VideoPlayer();
video = content.Load&lt;Video&gt;(&quot;Intro_Videos/main_intro&quot;);
videoPlayer.Play(video);

I get an error on line 2,

Microsoft.Xna.Framework.Content.ContentLoadException: &#39;Could not find ContentTypeReader Type. Please ensure the name of the Assembly that contains the Type matches the assembly in the full type name: Microsoft.Xna.Framework.Content.VideoReader (Microsoft.Xna.Framework.Content.VideoReader)&#39;

More detailed error below:

Microsoft.Xna.Framework.Content.ContentLoadException
  HResult=0x80131500
  Message=Could not find ContentTypeReader Type. Please ensure the name of the Assembly that contains the Type matches the assembly in the full type name: Microsoft.Xna.Framework.Content.VideoReader (Microsoft.Xna.Framework.Content.VideoReader)
  Source=MonoGame.Framework
  StackTrace:
   at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.LoadAssetReaders(ContentReader reader)
   at Microsoft.Xna.Framework.Content.ContentReader.InitializeTypeReaders()
   at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
   at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
   at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
   at DevcadeGame.States.IntroState..ctor(Game1 game, GraphicsDevice graphicsDevice, Int32 PreferredBackBufferWidth, Int32 PreferredBackBufferHeight, ContentManager content) in C:\Users\garre\Desktop\Devcade\Devcade-Hero\States\IntroState.cs:line 28
   at DevcadeGame.Game1.LoadContent() in C:\Users\garre\Desktop\Devcade\Devcade-Hero\Game1.cs:line 109
   at Microsoft.Xna.Framework.Game.Initialize()
   at DevcadeGame.Game1.Initialize() in C:\Users\garre\Desktop\Devcade\Devcade-Hero\Game1.cs:line 89
   at Microsoft.Xna.Framework.Game.DoInitialize()
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
   at Microsoft.Xna.Framework.Game.Run()
   at Program.&lt;Main&gt;$(String[] args) in C:\Users\garre\Desktop\Devcade\Devcade-Hero\Program.cs:line 3

Some more context is that the path should be right. The video is a .mp4, and the project builds just fine with the assets. I build on x86 (Active solution platform).

Any assistance would be appreciated.

答案1

得分: 0

VideoPlayer已经在Monogame中移除,引用Microsoft.Xna.Framework.Video与Monogame不兼容。

英文:

VideoPlayer has been removed in Monogame and referencing the Microsoft.Xna.Framework.Video was not compatible with Monogame.

huangapple
  • 本文由 发表于 2023年3月1日 13:36:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75599927.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定