英文:
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<Video>("Intro_Videos/main_intro");
videoPlayer.Play(video);
I get an error on line 2,
Microsoft.Xna.Framework.Content.ContentLoadException: '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)'
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.<Main>$(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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论