The video class exists in two libraries

In my Monogame project, I need to play a video. For this, I use the Video Class and VideoPlayer . But when I start the solution, VS gives me this error:

Error 1 Type "Microsoft.Xna.Framework.Media.Video" exists as in "c: \ Program Files (x86) \ Microsoft XNA \ XNA Game Studio \ v4.0 \ References \ Windows \ x86 \ Microsoft. Xna.Framework. Video.dll 'and' c: \ Program Files (x86) \ MonoGame \ v3.0 \ Assemblies \ WindowsGL \ MonoGame.Framework.dll '

I need the VideoPlayer class, which is located in Microsoft.Xna.Framework.Video.dll to play videos.

How can I solve this problem?

If this is useful, here is my code in which I want to play the video:

 namespace play { public class PlayVideoClass { private readonly Microsoft.Xna.Framework.Media.Video _video; private readonly Microsoft.Xna.Framework.Media.VideoPlayer _player; private bool _playVideo; public PlayVideoClass() { _video = Game1.Video; _player = new Microsoft.Xna.Framework.Media.VideoPlayer(); _playVideo = true; } public void Update() { if (_playVideo) { if ((int) _player.State == (int)Microsoft.Xna.Framework.Media.MediaState.Stopped) { _player.Play( _video); _playVideo = false; } } } } } 
+4
source share
1 answer

I think I have the best solution for you that reflection. You must create a separate assembly that will only have a link to the assembly that you want to use (Microsoft.Xna.Framework.Video.dll). You can write a wrapper for the type Microsoft.Xna.Framework.Media.Video. Your shell should reveal all the functionality that you want to use in your application. So, now this new assembly can resolve the correct type, because it has only one of them. Your application does not have to be aware of this conflict because it will use your type.

+1
source

All Articles