Search code examples
c#.netxnamonogamevideo-player

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


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.


Solution

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