0

I use Vlc.DotNet.Wpf, and I need the player to load the video and display only the first frame, so that the control gets a proper size and the user can see what the video is talking about, how can this be done?

if I call _vlcPlayer.SourceProvider.MediaPlayer.SetMedia(stream) nothing happend, and if I call _vlcPlayer.SourceProvider.MediaPlayer.Play(stream) the video running more than one frame.

I tried _vlcPlayer.SourceProvider.MediaPlayer.Time = 1 nothing happend.

How can this be done?

cube45
  • 3,429
  • 2
  • 24
  • 35
codeDom
  • 1,623
  • 18
  • 54

3 Answers3

1

You could parse the media and find its width and height from the first video track.

You could use the snapshot API to get a jpeg snapshot of the video that you could display. (That API will change in libvlc4)

You could also use play, and pause the video immediately after you get the Playing event (don't forget to switch threads).

cube45
  • 3,429
  • 2
  • 24
  • 35
1

Alternatively to cube45's answer, I believe there is a libvlc option just for that

--start-paused, --no-start-paused 
                                 Start paused
                                 (default disabled)
          Pause each item in the playlist on the first frame.

https://wiki.videolan.org/VLC_command-line_help

mfkl
  • 1,914
  • 1
  • 11
  • 21
  • It does not display the first frame and therefore does not update the control size – codeDom Jun 18 '20 at 12:44
  • Yes, of course. I tried in `Vlc.DotNet.Wpf`. `_vlcPlayer.SourceProvider.CreatePlayer(libDirectory, "--start-paused")` – codeDom Jun 18 '20 at 15:44
  • No I mean, have you tried in VLC media player, the application. It's a good way to troubleshoot to first try and make it work with the VLC app – mfkl Jun 18 '20 at 15:51
1

I got it to work with this code:

vlcVideoPlayer.VlcMediaplayerOptions = new string[]{"--start-paused"};
vlcVideoPlayer.Play(new Uri("Video Link/Directory"));
vlcVideoPlayer.Time = 1;

Hope it works for you.