Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

First off, sorry if this is a repeat question i didn't see anything similar in my searches.

The issue i am having....

When running an XNA game any Video objects & related Texture2D's are not being drawn properly. Only the bottom half of the videos are being drawn. the video still plays, and before/after any videos are played all other textures are properly drawn to the correct screen sizes.

Video Class from Microsoft.XNA.Framework.Graphics using Microsoft.Xna.Framework.Graphics; using System;

namespace Microsoft.Xna.Framework.Media
{
    // Summary:
    //     Represents a video.
    public sealed class Video
    {
        // Summary:
        //     Gets the duration of the Video.
        public TimeSpan Duration { get; }
        //
        // Summary:
        //     Gets the frame rate of this video.
        public float FramesPerSecond { get; }
        //
        // Summary:
        //     Gets the height of this video, in pixels.
        public int Height { get; }
        //
        // Summary:
        //     Gets the VideoSoundtrackType for this video.
        public VideoSoundtrackType VideoSoundtrackType { get; }
        //
        // Summary:
        //     Gets the width of this video, in pixels.
        public int Width { get; }
    }
}

Here is some of the code that would affect video textures and playback. please ignore any variable name differences and assume they are right in my working code. If you can think of anything that would be affecting the drawing of the videos that is not included in the following code let me know and i will see if i have something similar in my code and add it here. Again the issue is: videos being played are cut in half only the bottom half of videos are being drawn, any input that helps me find a solution to the issue is greatly appreciated.

namespace Picodroid
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public partial class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        GraphicsDevice device;

        .....

        DateTime developerDuration; // Video Duration

        .....

        int screenWidth;
        int screenHeight;
        float screenScale;

        .....

        Video developerVideo;
        Texture2D developVideoTexture;
        bool developer = true;

        // Constructor
        public Game1(int resolutionValue, int soundFxValue, int musicValue)
        { 
            this.resolutionValue = resolutionValue;
            this.soundFxValue = soundFxValue;
            this.musicValue = musicValue;

            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        } // End Constructor

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            device = graphics.GraphicsDevice;

            // current screen resolution

            float resolutionAdjustment;

            if (resolutionValue == 0)
                resolutionAdjustment = 1.0f / 3.0f;
            else if (resolutionValue == 1)
                resolutionAdjustment = 2.0f / 3.0f;
            else
                resolutionAdjustment = 1;

            if (device.DisplayMode.Width * resolutionAdjustment > 1920)
            {
                graphics.PreferredBackBufferWidth = 1920;

                float maxWidth = graphics.PreferredBackBufferWidth;
                float realWidth = device.DisplayMode.Width;
                float realHeight = device.DisplayMode.Height;
                float useHeight = (maxWidth / realWidth) * realHeight;

                graphics.PreferredBackBufferHeight = (int)useHeight;
            }
            else
            {
                graphics.PreferredBackBufferWidth = (int)(device.DisplayMode.Width * resolutionAdjustment);
                graphics.PreferredBackBufferHeight = (int)(device.DisplayMode.Height * resolutionAdjustment);
            }

            graphics.IsFullScreen = true;
            graphics.ApplyChanges();

            // screen
            screenWidth = device.PresentationParameters.BackBufferWidth;
            screenHeight = device.PresentationParameters.BackBufferHeight;
            screenScale = device.PresentationParameters.BackBufferWidth / 1920f;

            base.Initialize();
      } // End Initialize   

      /// <summary>
      /// LoadContent will be called once per game and is the place to load
      /// all of your content.
      /// </summary>
      protected override void LoadContent()
      {
           .....

           developerVideo = Content.Load<Video>("developer-100-audio-720");
           developerVideoTexture = Content.Load<Texture2D>("videoTexture");
           videoPlayer = new VideoPlayer();

           .....
      } // End LoadContent

      .....

      /// <summary>
      /// Allows the game to run logic such as updating the world,
      /// checking for collisions, gathering input, and playing audio.
      /// </summary>
      /// <param name="gameTime">Provides a snapshot of timing values.</param>

      // Note: Refer to Flow Chart and Update Method Hierarchy for details
      protected override void Update(GameTime gameTime)
      {

           .....

           if (developerDuration == DateTime.MinValue)
           {
                videoPlayer.Play(developerVideo);
                developerDuration = DateTime.Now;
           }

           .....

           base.Update(gameTime);
      } // End Update

      /// <summary>
      /// This is called when the game should draw itself.
      /// Drawing code goes here
      /// </summary>
      /// <param name="gameTime">Provides a snapshot of timing values.</param>

      // Note: Refer to the Draw Method Hierarchy for details
      protected override void Draw(GameTime gameTime)
      {
           float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

           GraphicsDevice.Clear(Color.Black);

           if (developer)
           {
                // Only call GetTexture if a video is playing or paused
                if (videoPlayer.State != MediaState.Stopped)
                     developVideoTexture = videoPlayer.GetTexture();

                float proportionalHeight = 1080f * screenScale;
                float heightDifference = screenHeight - proportionalHeight;

                if (heightDifference != 0)
                     heightDifference /= 2;

                // Draw the video, if we have a texture to draw.
                if (developVideoTexture != null)
                {
                     spriteBatch.Begin();
                     spriteBatch.Draw(developVideoTexture, new Vector2(0, heightDifference), null, Color.White, 0, Vector2.Zero,
                                 screenScale * 1.5f, SpriteEffects.None, 0);
                     spriteBatch.End();
                }
           }

           .....

           base.Draw(gameTime);
     } // End Draw
}
share|improve this question

3 Answers 3

up vote 1 down vote accepted

I didn't fully read your post, but take a look at this thread.

In stardrive, some videos are also displayed like this. It is caused by a bug in a Windows Update. (And I think stardrive also use XNA.)

You just have to uninstall this update (and deactivate the auto update mode). This will solve your problem.

share|improve this answer
    
Thank you, i removed the update and it fixed my issue –  ebellefontaine Jul 23 '13 at 15:59

If using windows 7 uninstall microsoft update: KB2803821

This also effects windows xp and windows vista. I'm not sure the KB# is the same for those OS's.

-michael

share|improve this answer

It is the same KB# for vista. Microsoft know about this issue. Not sure when they will have a fix. The security flaw they were fixing was in the rendering of video files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.