我尝试在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);
我在第二行得到一个错误,
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)'
更详细的错误如下:
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
一些更多的背景是路径应该是正确的。视频是一个IdeMP4,项目构建与资产刚刚好。我构建在x86(主动解决方案平台)上。
如有任何帮助,不胜感激。
1条答案
按热度按时间goqiplq21#
VideoPlayer已在Monogame中删除,引用Microsoft.Xna.Framework。视频与Monogame不兼容。