4

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

Error 1 The type 'Microsoft.Xna.Framework.Media.Video' exists in both '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 VideoPlayer class that it is in Microsoft.Xna.Framework.Video.dll for playing video.

How can I resolve this issue?

If it is helpful here is my code with I want to play 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;
                }
            }
        }
    }
}
joce
  • 9,624
  • 19
  • 56
  • 74
Dino Sauro
  • 167
  • 2
  • 2
  • 9

1 Answers1

1

I think that I have better solution for you that reflection. You should create separate Assembly which will have reference only to assembly which you want to use (Microsoft.Xna.Framework.Video.dll). You can write a wrapper for type Microsoft.Xna.Framework.Media.Video. Your wrapper should expose all functionality which you want to use in your application. So now this new assembly can resolve the right type, because it has only one of them. Your application will not need to know about this conflict, because it will use your type.

outcoldman
  • 11,584
  • 2
  • 26
  • 30
  • can you give me an example, please? With Video Class.. Because I try to do that but I didn't understand what I'm supposed to write.. Thanks in advice. – Dino Sauro Apr 06 '13 at 08:44
  • Could you show what did you do and what did not work for you? – outcoldman Apr 06 '13 at 15:50
  • I create a new dll project with vs2012: public class PlayVideo { private Video _video; private Microsoft.Xna.Framework.Media.VideoPlayer _player; private string name = "openClip"; public PlayVideo() { _video = new Video("I don't know what i put here... (Graphics device)", name, 50, 426, 240, 29, "I don't know what i put here... (VideoSountrackType)"); _player=new Microsoft.Xna.Framework.Media.VideoPlayer(); } Another problem is that Video vostructor give me error. – Dino Sauro Apr 07 '13 at 08:30
  • Error= Cannot access the costructor 'Video' here. – Dino Sauro Apr 07 '13 at 08:33
  • `"I don't know what i put here... (Graphics device)"` me either :) I guess you can try to put these as parameters of your class constructor PlayVideo. "Cannot access the costructor 'Video' here." is it build error? Did you reference `microsoft.xna.framework.video.dll`? – outcoldman Apr 07 '13 at 08:57
  • here my code https://bitbucket.org/dino_sauro/game/src/7006404319af2d776f55917615819128fbc8b01b/menu/VideoPlayer/Video.cs?at=master – Dino Sauro Apr 09 '13 at 16:39