2
Vote

Vlc player setMedia not work

description

I want to use VLC dotnet to develop a video management software for personal use. VLC is a good idea to take the different format Video snapshot.

I want take 4 snapshot each video. Unfortunately, player.GetMedia().Duration.TotalSeconds is always -0.001 that means media has not set to the player.

But I use player.play() that is work. How come?

I pull the Vlc dotnet from VS 2015 NuGet Package Manager. Less reference was found in internet so that ask for help in this platform. Hope anyone give me a hand.

Here is my code
            Vlc.DotNet.Core.VlcMediaPlayer player = new Vlc.DotNet.Core.VlcMediaPlayer(new System.IO.DirectoryInfo("C:\\Program Files (x86)\\VideoLAN\\VLC"));
            Vlc.DotNet.Core.VlcMedia media = player.SetMedia(new System.IO.FileInfo(videoFullPath));

            double len = player.GetMedia().Duration.TotalSeconds;
            interval = (int)(len * 0.95) / 4;
int counter = 0;
            for (int i = 0; i < len; i = i + interval)
            {
                player.Position = i;
                counter++;
                player.TakeSnapshot(
                    new System.IO.FileInfo(
                        storagePath + "\\" + screenShotPrefix
                                 + System.IO.Path.GetFileNameWithoutExtension(fileName)
                                 + "\\screenshot_" + counter.ToString() + counter.ToString() + ".jpg"
                  ), 320, 240);
            }

comments