Strange error while trying to play a video

Hello everyone,

I am new to monogame. I want to play a simple video. I did everything according to a tutorial on the internet and load a video content in .wmv format but i get this strange error saying:

Error Importer ‘WmvImporter’ had unexpected failure! PlayVideo C:/Users/berka/Desktop/Game Development/PlayVideo/PlayVideo/Content/nature.wmv

Error The command ““C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe” /quiet /platform:Windows /@:“C:\Users\berka\Desktop\Game Development\PlayVideo\PlayVideo\Content\Content.mgcb” /outputDir:“bin\Windows\Content” /intermediateDir:“obj\Windows\Content”” exited with code 1. PlayVideo

Where is the problem ? Below I post my code

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);
}

general: you sould load your content in the “LoadContent” Method :slight_smile:

the error you see is actually from the Content-Builder - which may or may not transcode it into a different format (I don’t know what it does) - so it’s not a problem with your code, but maybe with your video - what codec did you use? afaik, .wmv is just a container and does not tell about the codec

If the ContentBuilder fails, you cannot .Load it (because the file wont exist)

Hello @berkay_berabi and welcome to the forums.

Are you only developing for desktop? and Windows only?

As far as I am aware, I don’t think wmv will support all platforms, though I am not 100% certain on this via MonoGame… just mentioning this before you forget to explore other formats for the time being.

Happy Coding!

Thank you for your answer. I now moved loading part in to the LoadContent method. I do not know which codex the video has. I just downloaded a short video from youtube and converted it to .wmv. How can i find out the codec of the video ? and which codecs are then compatible with monogame ?

The target development environment is actually xbox1. Now, I am debugging on computer and sometime test on xbox1. Thank you for the information !

I do hope you don’t intend to use that video in your end product…

What tool did you use to convert it? it should give you the codec/conversion information…