I got it figured out:
It turns out that it was updating more than it was drawing, therefore it was translating objects and such much more than it should have per frame, so the playback was super fast. But I figured it out. Here's the code, feel free to use it for your needs.
Record and Playback:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using System.Threading;
namespace WAR
{
class VideoPlayback
{
string directory;
int frame = 1;
ContentManager manager;
GraphicsDevice device;
Texture2D playback;
SpriteBatch playbackbatch;
public VideoPlayback(string Directory, ContentManager Manager, GraphicsDevice Device)
{
directory = Directory;
manager = Manager;
device = Device;
playbackbatch = new SpriteBatch(device);
}
public void Playback(int EndOfPlayback)
{
playback = manager.Load<Texture2D>("Content\\Video\\VideoPlaybackscreenCapture" + frame.ToString());
if (frame < EndOfPlayback)
frame++;
else
frame = 1;
playbackbatch.Begin();
playbackbatch.Draw(playback, Vector2.Zero, Color.White);
playbackbatch.End();
}
public void Record()
{
using (Texture2D screenshot = new Texture2D(device,
(int)device.Viewport.Width, (int)device.Viewport.Height,
1, ResourceUsage.ResolveTarget,
SurfaceFormat.Color, ResourceManagementMode.Manual))
{
device.ResolveBackBuffer(screenshot);
screenshot.Save(directory + "screenCapture" + frame + ".png", ImageFileFormat.Png);
}
frame++;
}
}
}
Note: Recording is really slow. To record: VideoPlayback.Record(); To playback: VideoPlayback.Playback(NumFrames); Be aware - playback expects the files to be inside the "bin/x86/Debug/Content/Video" folder. Sorry. Still haven't worked out recording sound, so any help is accepted.
Tracking draw/update whilst recording:
protected override void Draw(GameTime gameTime)
{
hasBeenDrawn = true;
...
protected override void Update(GameTime gameTime)
{
...
if (hasBeenDrawn)
//do updatey stuff
Glad I could give back to the community with this.
==============================
Don't sweat the petty stuff and don't pet the sweaty stuff.
==============================