Is there any way to play mpg files in XNA? (I want to develop a game that a video stream has to play at background)
+2
A:
XNA has built-in video playback. A good place to get started using it might be Catalin's XNA 3.1 Video Sample.
One downside to XNA's built-in functionality is that it has limited format support (specifically WMV9). So you will need to convert your video to that format. Two options for encoding are Windows Movie Maker and Windows Media Encoder (which seems to have recently become Expression Encoder 4).
Once in that format, you can simply add it as content to your project. Then load it as a Video through the content manager, and use VideoPlayer to play it back, calling videoPlayer.GetTexture()
to get a texture of the current video frame you can set on the device or pass to spriteBatch.Draw()
.
Andrew Russell
2010-06-30 00:51:58