XNA VideoPlayer对象导致“ CrossThreadMessagingException” [英] XNA VideoPlayer object causes 'CrossThreadMessagingException'

查看:90
本文介绍了XNA VideoPlayer对象导致“ CrossThreadMessagingException”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(关于我之前的问题:播放视频(MSDN教程)



我遇到以下问题:当我尝试读取XNA VideoPlayer对象的状态时,出现了 CrossThreadMessagingException 。意思是,我正在尝试从其他线程中读取内容。

关于如何解决此问题的任何想法? (是否有办法告诉VideoPlayer对象在缓冲区中写入内容?)



代码:

 受保护的重写void Update(GameTime gameTime)
{
//如果(GamePad.GetState(PlayerIndex.One).Buttons,允许游戏退出
.Back == ButtonState.Pressed)
this.Exit();

if(player.State == MediaState.Stopped)//导致异常
{
player.IsLooped = true;
player.Play(视频); //导致神秘的崩溃
}

// ...
}

错误消息:


player.State ='player.State'抛出了

类型的例外

'Microsoft。 VisualStudio.Debugger.Runtime.CrossThreadMessagingException'



解决方案

是的,显然不是他有这个问题,因为我也有同样的问题,可以在我的计算机上正常工作,可以连接到360和 BANG, CRASH, BOOM。我正在其他论坛上进行研究,并在寻找答案时找到了它。



Jason



Sylven游戏开发


(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

这篇关于XNA VideoPlayer对象导致“ CrossThreadMessagingException”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆