使用XNA在Monogame中播放视频时出现奇怪的错误

时间:2019-04-06 11:30:31

标签: c# video xna monogame

我正在尝试在一个单人游戏项目中播放视频。我完成了与教程有关的所有工作,并加载了视频内容,但出现错误

错误导入器'WmvImporter'发生意外故障! PlayVideo C:/ Users / berka / Desktop / Game Development / PlayVideo / PlayVideo / Content / nature.wmv

错误命令““ C:\ Program Files(x86)\ MSBuild \ MonoGame \ v3.0 \ Tools \ MGCB.exe” / quiet / platform:Windows / @:“ C:\ Users \ berka \ Desktop \游戏开发\ PlayVideo \ PlayVideo \ Content \ Content.mgcb“ / outputDir:” bin \ Windows \ Content“ / intermediateDir:” obj \ Windows \ Content“”以代码1退出。PlayVideo

代码实际上是非常基本的。我张贴了我不知道为什么它不起作用。任何帮助表示赞赏。先感谢您 !

    protected override void Initialize()
    {
        // TODO: Add your initialization logic here

        video = Content.Load<Video>("nature");
        videoPlayer = new VideoPlayer();


        base.Initialize();
    }


    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);
        videoPlayer.Play(video);
        // TODO: use this.Content to load your game content here
    }



    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        spriteBatch.Begin();

        Texture2D videoTexture = null;

        if(videoPlayer.State != MediaState.Stopped)
        {
            videoTexture = videoPlayer.GetTexture();
        }

        if(videoTexture != null)
        {
            spriteBatch.Draw(videoTexture, new Rectangle(0, 0, 400, 240), Color.White);
        }

        spriteBatch.End();

        // TODO: Add your drawing code here

        base.Draw(gameTime);
    }

0 个答案:

没有答案