How to use Video in XNA

In this mini-article I will show you how to use Video in XNA.

We have a project Structure like this:


We will be using Wildlife.wmv for demonstration in our sample(which can be found in your Videos folder inside My Documents)

We are adding these variables first:

Video myVideoFile;
VideoPlayer videoPlayer = new VideoPlayer();

After that add these to LoadContent:

myVideoFile = Content.Load<Video>("Videos\\Wildlife");

Inside Update call:


And in Draw Function:

spriteBatch.Draw(videoPlayer.GetTexture(), new Rectangle(0, 0, myVideoFile.Width, myVideoFile.Height),Color.CornflowerBlue);

When you run the project you will see a video running inside XNA Window.


Well Done. You have successfully displayed Video in XNA.