(Relating to an earlier question of mine: Playing a Video (MSDN Tutorial))
I have the following problem: When I’m trying to read the state of a XNA VideoPlayer object I get an CrossThreadMessagingException. Meaning, I’m trying to read from a different thread. This seems to be not allowed (I have no idea how threads work in C# internally 🙂
Any ideas on how to fix this? (Is there a way to tell the VideoPlayer object to write in a buffer or something?)
Code:
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (player.State == MediaState.Stopped) //Causes the exception
{
player.IsLooped = true;
player.Play(video); //Causes the "mysterious" crash
}
// ...
}
Error Message:
player.State = 'player.State' threw an
exception of type
'Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException'
Yeah well it’s apparently not just this him having the issue as I have the exact same problem , works fine on my computer, port to the 360 and “BANG” “CRASH” “BOOM”. I’m working on it in other forums and found this while searching for an answer.
Jason
Sylven Game Development